diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-03 12:52:34 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-03 12:52:34 -0400 |
| commit | 66d0374a232c7fb7c3d443b081ae231ea249511a (patch) | |
| tree | f6c11fa9d42357536ec4cb031a02c00bca80c524 | |
| parent | 5a368128ebd7a2d2f114883d3b6cfbad12913123 (diff) | |
Iterative version of Indices
| -rw-r--r-- | impl.bqn | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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=≠) |
