aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/r1.bqn33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/r1.bqn b/src/r1.bqn
index 9351c986..afc31ddc 100644
--- a/src/r1.bqn
+++ b/src/r1.bqn
@@ -261,6 +261,8 @@ IsPure ← {d←Decompose𝕩 ⋄ 2⊸≤◶⟨≤⟜0, 1×´·𝕊⌜1↓d˙⟩
_fillByPure_←{
𝕘 (3≤Type∘⊣)◶⟨{𝕨Fill𝕏},{(𝕨HomFil𝕩)_fillBy_𝕨}⍟(IsPure⊣)⟩ 𝕗
}
+_each ← {𝕨𝔽⌜⊘(𝔽_eachd)_fillByPure_𝔽○ToArray𝕩}
+_table ← {𝕨𝔽⌜_fillByPure_𝔽○ToArray𝕩}
StructErr←{𝕩}
IsStructErr ← (3=Type)◶⟨0,StructErr˙⊸=⟩
@@ -488,7 +490,17 @@ Windows←{
}_fillBy_⊢⍟(0<r)𝕩
}
-˘ ← {𝕨 𝔽 _rankOp_ ¯1 𝕩}
+EncCell ← {
+ f←𝕨↑≢𝕩 ⋄ c←1×´s←𝕨Cell𝕩 ⋄ d←⥊𝕩
+ i←s⥊↕c
+ (f⥊{d⊏˜(c×𝕩)⊸+⌜i}⌜↕1×´f)˙_fillBy_{(<𝕩)⌜i} 𝕩
+}
+˘ ← {
+ F←𝔽 ⋄ _m←{𝔽⌜⊘(𝔽¨)_fillByPure_𝔽○(1⊸EncCell)}
+ D←{ "˘: Argument lengths don't agree" ! 𝕩=○≠𝕨 ⋄ 𝕨 F _m 𝕩 }
+ Merge 𝕨 2⊸×⊸+○(0<=)◶⟨ToArray F,{𝕨⊸F _m𝕩},{F⟜𝕩_m𝕨},D⟩ 𝕩
+}
+
_onAxes_←{
F←𝔽
(𝔾<≡)∘⊣◶{ # One axis
@@ -653,26 +665,23 @@ GroupM←{
(LS 0⌜𝕨) Fill dr (1≠≠∘⊢)◶⟨S _group○(0⊸⊑), S⌜ ·+⌜⌜´ (⌽×`1»⌽l) × ⊢_group¨⟩ 𝕨
}
-¨ ← {𝕨𝔽⌜⊘(𝔽_eachd)_fillByPure_𝔽○ToArray𝕩}
-_ranks ← {⟨2⟩⊘⟨1,0⟩ ((⊣-1+|)˜⟜≠⊑¨<∘⊢) ValidateRanks∘𝔽}
+_ranks ← {⟨2⟩⊘⟨1,0⟩ ((⊣-1+|)˜⟜≠⊑⌜<∘⊢) ValidateRanks∘𝔽}
_depthOp_←{
neg←0>n←𝕨𝔾_ranks𝕩 ⋄ F←𝔽
_d←{
R←(𝕗+neg)_d
- 𝕨(×⟜2⊸+´2 Reshape (neg∧𝕗≥0)∨(0⌈𝕗)≥Pair○≡)◶⟨R¨⋄R⟜𝕩⌜∘⊣⋄(𝕨R⊢)⌜∘⊢⋄F⟩𝕩
+ 𝕨(×⟜2⊸+´2 Reshape (neg∧𝕗≥0)∨(0⌈𝕗)≥Pair○≡)◶⟨
+ R _each, R⟜𝕩_table∘⊣, (𝕨R⊢)_table∘⊢, F
+ ⟩𝕩
}
𝕨 n _d 𝕩
}
_rankOp_←{
k←𝕨(Pair○= (0≤⊢)◶⟨⌊⟜-,0⌈-⟩¨ 𝔾_ranks)𝕩
- Enc←{
- f←(↕𝕨)⊏≢𝕩
- c←1×´s←𝕨Cell𝕩⋄i←s⥊↕c
- (f⥊((⥊𝕩)⊏˜i+c×⊢)⌜↕1×´f)˙_fillBy_{(<𝕩)⌜i} 𝕩
- }
- Enc↩(>⟜0×1+≥⟜=)◶⟨<⊢,Enc,<⌜⊢⟩
- > ((0⊑k)Enc𝕨) 𝔽¨ ((1-˜≠)⊸⊑k)Enc𝕩
+ Enc←(>⟜0×1+≥⟜=)◶⟨<⊢,EncCell,<_table⊢⟩
+ > ((0⊑k)Enc𝕨) 𝔽_each ((1-˜≠)⊸⊑k)Enc𝕩
}
+¨ ↩ _each
↑ ↩ Prefixes ⊘ Take
↓ ↩ Suffixes ⊘ Drop
@@ -796,7 +805,7 @@ SwapInverse ← INF _lookup_ ⟨
'∨', (¬√∘¬)⊘(-˜÷1-⊣)
'¬', IA∘0⊘(+-1˙)
-⌜ ↩ {𝕨𝔽⌜_fillByPure_𝔽○ToArray𝕩}
+⌜ ↩ _table
Mod1Inverse ← INF˙ _lookup_ ⟨
'˜', SwapInverse
'¨', {𝕏⁼¨ ⊣·IX 0<≡∘⊢}