aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-08 10:53:05 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-08 10:58:21 -0400
commitd232168a333f9b0a7675ab3829f0c34af0783883 (patch)
tree322a470c397795a1d6e249c9087a1638a5563920 /src
parente34577b432ad308d4f88e65784b68f81eebd4ed4 (diff)
Non-pervasive Merge implementation
Diffstat (limited to 'src')
-rw-r--r--src/r.bqn24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/r.bqn b/src/r.bqn
index d153a53d..264245a1 100644
--- a/src/r.bqn
+++ b/src/r.bqn
@@ -111,6 +111,8 @@ _under_←{
s⥊{e=𝕩}◶⟨⊑⟜(⥊𝕩),{𝕩⋄r←(j⊑g)⊑v⋄e↩P j↩1+j⋄r}⟩⌜i
}
+Deshape←IsArray◶{⟨𝕩⟩}‿⥊
+
¨ ↩ {(𝔽⌜)⊘(𝔽_eachd)○ToArray}
match←{(0⊑𝕨)◶(1⊑𝕨)‿𝕩}´⟨
@@ -120,6 +122,15 @@ match←{(0⊑𝕨)◶(1⊑𝕨)‿𝕩}´⟨
⟨1×´=¨○≢ , 0⟩
{1×´⥊𝕨Match¨𝕩}
+Depth←IsArray◶0‿{1+0(⊣-≤×-)´Depth⌜⥊𝕩}
+
+≡ ← Depth ⊘ Match
+
+Merge←{
+ c←≢0⊑⥊𝕩
+ ! 1×´(c≡≢)⌜⥊𝕩
+ 𝕩⊑⟜Deshape˜⌜c⥊↕1×´c
+}⍟(0<≠∘⥊)⍟IsArray
+ ↩ + _perv
- ↩ - _perv
@@ -134,7 +145,7 @@ match←{(0⊑𝕨)◶(1⊑𝕨)‿𝕩}´⟨
∧ ← ×
∨ ← (+-×)
< ↩ {⟨⟩⥊⟨𝕩⟩} ⊘ ((1-≤˜) _perv)
-> ↩ (1-≤) _perv
+> ↩ Merge ⊘ ((1-≤) _perv)
≠ ↩ ≠ ⊘ ((1-=) _perv)
= ↩ = ⊘ (= _perv)
≥ ← !∘0 ⊘ (≤˜_perv)
@@ -154,8 +165,6 @@ SelSub←{
}𝕩
}
-
-Deshape←IsArray◶{⟨𝕩⟩}‿⥊
Reshape←{
! 1≥=𝕨
𝕨↩Deshape 𝕨
@@ -174,20 +183,11 @@ Range←{
IsArray◶I‿M 𝕩
}
-Depth←IsArray◶0‿{1+0⌈´Depth⌜⥊𝕩}
-
-≡ ← Depth ⊘ Match
≢ ↩ ≢ ⊘ (¬Match)
Pair ← {⟨𝕩⟩} ⊘ {⟨𝕨,𝕩⟩}
-Merge←{
- c←≢0⊑⥊𝕩
- ! ∧´(c≡≢)⌜⥊𝕩
- 𝕩⊑⟜⥊˜⌜c⥊↕×´c
-}⍟(0<≠∘⥊)
-> ↩ Merge ⊘ >
≍ ← >∘Pair
_ranks ← {⟨2⟩⊘⟨1,0⟩((⊣-1+|)˜⟜≠⊑¨<∘⊢)⥊∘𝔽}
_depthOp_←{