aboutsummaryrefslogtreecommitdiff
path: root/impl.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-03 12:52:34 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-03 12:52:34 -0400
commit66d0374a232c7fb7c3d443b081ae231ea249511a (patch)
treef6c11fa9d42357536ec4cb031a02c00bca80c524 /impl.bqn
parent5a368128ebd7a2d2f114883d3b6cfbad12913123 (diff)
Iterative version of Indices
Diffstat (limited to 'impl.bqn')
-rw-r--r--impl.bqn16
1 files changed, 11 insertions, 5 deletions
diff --git a/impl.bqn b/impl.bqn
index 8579e2b5..4a1c82bb 100644
--- a/impl.bqn
+++ b/impl.bqn
@@ -66,6 +66,17 @@ match←{(0⊑𝕨)◶(1⊑𝕨)‿𝕩}´⟨
{1×´⥊𝕨Match¨𝕩}
+Indices←{
+ ! 1==𝕩
+ l←≠𝕩
+ {
+ ! 1×´Nat¨𝕩
+ es ← +`𝕩 ⋄ e←0 ⋄ Ei←{e↩𝕩⊑es}
+ Ei i←0
+ {j←𝕩⋄U←{U⍟(j=Ei)1+𝕩}⋄{i↩U𝕩}⍟(𝕩=e)i}¨↕(l-1)⊑es
+ }⍟(0<l)𝕩
+}
+
+ ↩ + _perv
- ↩ - _perv
× ↩ (0⊸(<->) ⊘ ×) _perv
@@ -232,11 +243,6 @@ Windows←{
Reverse ← {!1≤=𝕩 ⋄ (-↕⊸¬≠𝕩)⊏𝕩}
Rotate ← {!Int𝕨 ⋄ l←≠𝕩⋄(l|𝕨+↕l)⊏𝕩} _onAxes_ 0
-Indices←{
- ! 1==𝕩
- ! ∧´Nat¨𝕩
- ⟨⟩∾´𝕩⥊¨↕≠𝕩
-}
Rep ← Indices⊸⊏
Replicate ← {0<=𝕨}◶(⥊˜⟜≠Rep⊢)‿{!𝕨=○≠𝕩⋄𝕨Rep𝕩} _onAxes_ (1-0=≠)