From 7025dfed3ef57840286d81a19cac517bcd62f321 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 3 Aug 2020 13:37:35 -0400 Subject: Non-recursive iterative Indices by scanning backwards for nonzeros --- impl.bqn | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/impl.bqn b/impl.bqn index 4a1c82bb..79c64fa3 100644 --- a/impl.bqn +++ b/impl.bqn @@ -71,9 +71,11 @@ Indices←{ 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 + k←l-1 + N ← ((⊢+-×0=𝕩⊑˜⊢)`k⊸-⌜↕l)⊑˜k-⊢ # Next nonzero + E ← ⊑⟜(+`𝕩) + ei←E i←N 0 + {{ei↩E i↩N𝕩+1⋄i}⍟(𝕩=ei)i}¨↕E k }⍟(0