:D  Thanks for the explanation, I understand now; for the real task, there
is a specific argument which I did not see, and I never will  :)

On Thu, Dec 7, 2017 at 5:50 PM, Arie Groeneveld <[email protected]>
wrote:

> I understand. It's perfect for working with the small example inputs.
> Thanks for the patch.
>
> For the real task using ^:a:  destroys my J session so I modified the verb
> using ^:(_) and a 'local' counter (first box contains the number of jumps)
> . That's all.
>
>
>
> Op 07-12-17 om 23:27 schreef Jose Mario Quintana:
>
> Oh, maybe I was not clear enough, the verb,
>>
>> cj=. <:@:#@:((([ + (- (_ * 0 > ]))@:[ { ]) ; >:@{`[`]})&>/ ::]^:a:@(0&;))
>>
>> is meant to be a patched version of your original verb based on the form
>> ^:a:,
>>
>>               (([ +                    {  ) ; >:@{`[`]})&>/ ::]^:a:@(0&;)
>>
>> and it seems to produce the same number of jumps answers as those produced
>> by,
>>
>> ((1+0&{::);((+_*0>])@([+{);>:@{`[`]})&>/@}.) ::]^:(_)
>>
>> for a couple of examples; namely,
>>
>>     cj 0 3 0 1 _3
>> 5
>>     cj 0 _2 0 0
>> 3
>>
>> vis-a-vis
>>
>>      ((1+0&{::);((+_*0>])@([+{);>:@{`[`]})&>/@}.) ::]^:(_) 0;0;0 3 0 1 _3
>> ┌─┬─┬──────────┐
>> │5│5│2 5 0 1 _2│
>> └─┴─┴──────────┘
>>      ((1+0&{::);((+_*0>])@([+{);>:@{`[`]})&>/@}.) ::]^:(_) 0;0;0 _2 0 0
>> ┌─┬─┬────────┐
>> │3│_│2 _1 0 0│
>> └─┴─┴────────┘
>>
>> I thought the exercise was just to find the number of jumps...  Is it not?
>>
>> Perhaps I am still making more noise :)
>>
>>
>>
>> On Thu, Dec 7, 2017 at 2:19 PM, Arie Groeneveld <[email protected]
>> >
>> wrote:
>>
>>
>>> Op 07-12-17 om 18:27 schreef Jose Mario Quintana:
>>>
>>> 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.
>>>>
>>>> kind of, so forcing the index to plus infinite will do the job:
>>>
>>>     ((1+0&{::);((+_*0>])@([+{);>:@{`[`]})&>/@}.) ::]^:(_) 0;0;0 _2 0 0
>>> ┌─┬─┬────────┐
>>> │3│_│2 _1 0 0│
>>> └─┴─┴────────┘
>>>
>>>
>>>     Moreover,
>>>
>>>> counting the jumps in this context seems to be the number of the
>>>> resulting
>>>> items minus one; thus,
>>>>
>>>> no, not for this task. It destroys my J session. So I need a counter.
>>>
>>>
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
> ----------------------------------------------------------------------
> 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