aboutsummaryrefslogtreecommitdiff
path: root/src/r1.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-03-28 17:07:31 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-03-28 17:07:31 -0400
commitcf4d42fc8ea7875a7df2e85688d1466ebbbbc36b (patch)
tree070324d84c84c99d3a5f5bd75f5c4dc54b583b15 /src/r1.bqn
parentab0c110db931360231647e512d3323e82c06c345 (diff)
Support for ∾ and > in Under
Diffstat (limited to 'src/r1.bqn')
-rw-r--r--src/r1.bqn25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/r1.bqn b/src/r1.bqn
index f694b2fc..e34d28ba 100644
--- a/src/r1.bqn
+++ b/src/r1.bqn
@@ -377,12 +377,17 @@ under←{
Expand ← {
f‿a‿i‿q←𝕩 ⋄ e←i⊑⥊a
- ⟨IsArray◶⟨⟨⟩,∾⟜⟨i⟩⟩f,e,IsArray◶⟨0,@Fill⥊⟜(↕1×´⊢)∘≢⟩e,q⟩
+ Expand2⍟(2=𝕨) ⟨IsArray◶⟨⟨⟩,∾⟜⟨i⟩⟩f,e,IsArray◶⟨0,@Fill⥊⟜(↕1×´⊢)∘≢⟩e,q⟩
+ }⍟(>⟜(IsArray 2⊑⊢))
+ Expand2 ← {
+ xf‿xa‿xi‿xq ← 𝕩
+ i ← { f‿a‿i‿q←1 Expand xf‿xa‿𝕩‿xq ⋄ {f‿a‿𝕩‿q _s}⍟(1-IsStruct)⌜i }⌜ xi
+ ⟨⟩‿@‿i‿⟨1,1⟩
}
_s ← {
⟨st,d‿o⟩←𝕩 # Function, input depth, output is structural
- f‿a‿i‿⟨q,r⟩←Expand⍟(d>·IsArray 2⊑⊢)𝕗 # Path, array reference, indices, info
- {f‿a‿𝕩‿⟨q⌈1<o,r⟩ _s}⍟(0<o) 𝕨 St i
+ f‿a‿i‿⟨q,r⟩←d Expand 𝕗 # Path, array reference, indices, info
+ {f‿a‿𝕩‿⟨q⌈1<o,r⟩ _s}⍟(1-IsStruct)⍟(0<o) 𝕨 St i
}
IsStruct ← (StructD←(4=0⊸⊑)◶⟨0,s˙=2⊸⊑⟩) {Decompose𝕩}
NS ← IsStruct _errIf
@@ -392,6 +397,15 @@ under←{
a ← Decompose⊸(1⊸⊑⊸((0<·≠0⊑⊣)◶⟨SD 2⊑⊣,{r↩1⋄𝕩}⟩) ⍟(StructD⊣)) _perv 𝕩
⟨⟩‿@‿a‿⟨d,r⟩ _s
}
+ _nested ← {
+ p0‿p1←(⌊⋈⌈)´pw‿px←0⊸⊑⌜a←(1 Expand 1⊑Decompose)⌜ 𝕨‿𝕩
+ p ← 0+´×`(⊑⟜pw=⊑⟜px)⌜↕p0
+ (p↓0⊑a)
+ (p=p1)◶⟨
+ Nest 𝔽○{f‿a‿i‿q←𝕩⋄{f‿a‿𝕩‿q _s}⌜i}
+ {𝕩_s}(2↑⊢)∾𝔽○(2⊸⊑)⋈⌈¨○(3⊑⊢)
+ ⟩´a
+ }
_amb ← {(IsStruct⊢)◶⟨𝕏, 𝕩‿𝕗{𝕨𝕏𝕗}⟩}
_mon ← {(𝕗_amb𝕩)⊘(NS𝕩)}
@@ -408,8 +422,8 @@ under←{
"⥊⌽⍉⊏", 1‿1 _amb
"↑↓", {(1‿2 _amb𝕩)⊘(1‿1 _amb𝕩)}
"⊑", 1‿2 _amb
- # ">", 2‿1 _mon
- # "∾", 2‿1 _mon # Dyad combines
+ ">", 2‿1 _mon
+ "∾", 2‿1 {+○IsStruct◶⟨𝕏, 𝕩‿𝕗{𝕨𝕏𝕗}⊘E, 𝕏_nested⟩}
# "˘⎉¨⌜",
# "⚇",
@@ -472,7 +486,6 @@ under←{
_indRec ← {
root‿x←𝕗 ⋄ iv←𝕩
- "TODO"!0=≠root
l ← GroupLen i ← (1=Type)◶⟨0⊑0⊑1⊑Decompose,¯1⟩⌜ 0⊑iv
ind‿val ← (l GroupOrd i)⊸⊏⌜ iv ⋄ rec←0
ic ← (1<·≠0⊑⊢)◶⟨2⊑⊢,{rec↩1⋄𝕩_s}(⋈1↓0⊑⊢)∾1↓⊢⟩∘(1⊑Decompose)⌜ ind