upd=:(1+0&{::);(([+{);>:@{`[`]})&>/@}.
upd ::]^:(_) f. 0; 0;r
NB. in case of a neg index use
p=:(0<:1&{::)*.(1&{::<#@(2&{::))
upd ^:p^:(_) f. 0; 0;r
I tried using a version without boxing, but that was slower.
upd2 ^: p2 ^: counter, start, r
Op 07-12-17 om 16:15 schreef Arie Groeneveld:
... and that doesn't work for the real task I realize. Should add a
counter and use _ instead of a:
Op 07-12-17 om 07:30 schreef Arie Groeneveld:
<:@#(([+{);>:@{`[`]})&>/^:(((0<:[)*.(<#))&>/)^:a:@(0&;)0 _2 0 0
3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm