aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-06 15:43:04 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-06 15:43:04 -0400
commit920a06ebc26ae925ecd2b975c07a56db63109b43 (patch)
tree7cf1104ac27bef9b90dcb0451c5fb830c382f47d
parent6c6aa96dc7c6cf76e4de55e6389716f4b082b7b7 (diff)
Faster structural Under: only grade the inserted indices
-rw-r--r--impl.bqn17
1 files changed, 10 insertions, 7 deletions
diff --git a/impl.bqn b/impl.bqn
index fafbad43..90d5f6fb 100644
--- a/impl.bqn
+++ b/impl.bqn
@@ -106,6 +106,16 @@ Indices←{
}⍟(0<l)𝕩
}
+_under_←{
+ i←↕l←1×´s←≢𝕩
+ v←⥊𝕨𝔽○𝔾𝕩
+ g←Cmp0 _grade gi←⥊𝔾s⥊i
+ P←(≠g)⊸≤◶⟨(⊑⟜g)⊑gi˜,l⟩
+ e←P j←0
+ s⥊{e=𝕩}◶⟨⊑⟜(⥊𝕩),{𝕩⋄r←(j⊑g)⊑v⋄e↩P j↩1+j⋄r}⟩¨i
+}
+⌾ ← _under_
+
+ ↩ + _perv
- ↩ - _perv
× ↩ (0⊸(<->) ⊘ ×) _perv
@@ -441,10 +451,3 @@ _repeat_←{
(|⊑<⟜0⊑pos‿neg˜)⚇0 n
}
⍟ ↩ _repeat_
-
-_under_←{
- i←↕×´s←≢𝕩
- v←⥊𝕨𝔽○𝔾𝕩⋄gi←⥊𝔾s⥊i⋄k←¬i∊gi
- s⥊(⍋(/k)∾gi)⊏(k/⥊𝕩)∾v
-}
-⌾ ← _under_