I really do not know exactly what the original was doing, or what the task
really is, but if the issue was that negative indices are valid for { then
replacing it by (- (_ * 0 > ]))@:[ { ] should do the trick.  Moreover,
counting the jumps in this context seems to be the number of the resulting
items minus one; thus,

   cj=. <:@:#@:((([ + (- (_ * 0 > ]))@:[ { ]) ; >:@{`[`]})&>/ ::]^:a:@(0&;))

   cj 0 3 0 1 _3
5
   cj 0 _2 0 0
3

My apologies in advance for any potential noise.


On Thu, Dec 7, 2017 at 11:04 AM, Arie Groeneveld <[email protected]>
wrote:

> 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to