From 66d0374a232c7fb7c3d443b081ae231ea249511a Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 3 Aug 2020 12:52:34 -0400 Subject: Iterative version of Indices --- impl.bqn | 16 +++++++++++----- 1 file 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) ⊘ ×) _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=≠) -- cgit v1.2.3