aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-12 20:24:39 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-12 20:24:39 -0500
commit4876f753e51dfb2300586bcd43301fa5c039b5b3 (patch)
treeb1bd599ca08b21ef61c34d3db33cb13eee10a74c /src
parent2a484a64bf08ce5fb14b13d01d42f9a76a141bb9 (diff)
Move StructPrimClass lookup outside of _structural for performance
Diffstat (limited to 'src')
-rw-r--r--src/r.bqn42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/r.bqn b/src/r.bqn
index 6392154f..7f99d2c5 100644
--- a/src/r.bqn
+++ b/src/r.bqn
@@ -722,6 +722,18 @@ Recompose ← ⊣◶⟨
{F‿m←𝕩⋄F _m} # 4 1-modifier
{F‿m‿G←𝕩⋄F _m_ G} # 5 2-modifier
+structPrimClass ← {((/∾≠)≠¨𝕩)⊑˜·⊑(∾𝕩)⊐<} ⥊¨ ⟨
+ ⊢‿⊣‿˜‿∘‿○‿⊸‿⟜‿⊘‿◶
+ =‿≠‿≢
+ <
+ ≍
+ ↕‿/‿»‿«‿⊔
+ ⥊‿↑‿↓‿⌽‿⍉‿⊏‿⊑
+# >
+# ∾
+# ˘⎉¨⌜
+# ⚇
+⟩
_structural←{
E←StructErr˙
Inds ← ⥊⟜(↕1×´⊢)∘≢⍟(¬IsStructErr) 𝕩 IsArray∘⊢◶⟨E,⊑⟜⥊⟩´ ⌽
@@ -737,28 +749,22 @@ _structural←{
Mon←{𝕏⊘E} ⋄ Dy←{E⊘𝕏}
SE ← {⊢⊘∨○IsStructErr◶⟨𝕏,StructErr˙⟩}⍟(3≥Type)
- _lk_ ← {
- s ← 2×↕(≠𝕘)÷2
- p ← ⥊¨s⊏𝕘
- (⊑(∾p)⊐<)◶((p≠¨⊸/(1+s)⊏𝕘)∾⟨𝕗⟩)
- }
- StructPrim ← (3=Type)◶⟨E˙,{⊢⊘∨○IsStruct◶⟨𝕏,StructErr˙⟩}⟩ _lk_ ⟨
- ⊢‿⊣‿˜‿∘‿○‿⊸‿⟜‿⊘‿◶, ⊢
- =‿≠‿≢ , Mon 1⊸Info
- < , Mon 0⊸Depth
- ≍ , Mon 1⊸Depth # Dyad combines
- ↕‿/‿»‿«‿⊔ , Dy 1⊸Depth
- ⥊‿↑‿↓‿⌽‿⍉‿⊏‿⊑ , 1⊸Depth
- # > , Mon 2⊸Depth
- # ∾ , Mon 2⊸Depth # Dyad combines
- # ˘⎉¨⌜
- # ⚇
- ⟩
+ StructPrim ← ⊢ {𝕏𝕨} StructPrimClass ⊑ ⟨
+ ⊢ # ⊢⊣˜∘○⊸⟜⊘◶
+ Mon 1⊸Info # =≠≢
+ Mon 0⊸Depth # <
+ Mon 1⊸Depth # ≍ # Dyad combines
+ Dy 1⊸Depth # ↕/»«⊔
+ 1⊸Depth # ⥊↑↓⌽⍉⊏⊑
+ # Mon 2⊸Depth # >
+ # Mon 2⊸Depth # ∾ # Dyad combines
+ (3=Type)◶⟨E˙,{⊢⊘∨○IsStruct◶⟨𝕏,StructErr˙⟩}⟩
+ ⟩˙
StructFn ← (⊑ ⌊⟜2◶⟨
SE · StructPrim ⊑∘⊢ # 0 primitive
StructErr˙ # 1 block
Recompose⟜{StructFn¨𝕩} # other operation
SE ⊑∘⊢ # ¯1 constant
⟩ 1⊸↓) Decompose
- IsStruct◶⟨@‿StructErr,1‿3⊏Decompose⟩ {𝕎𝕩}´ ⟨StructFn 𝕗, ¯1 _s_ 0⟩
+ IsStruct◶⟨0‿StructErr,1‿3⊏Decompose⟩ {𝕎𝕩}´ ⟨StructFn 𝕗, ¯1 _s_ 0⟩
}