Pascal Jasmin wrote:
>    a =: 44 _78 _3 32 7 2 _9 33 9 183 _350 _34 44 75 17 22 19 _190 120
19 7 3 29 8 65 42 2 88 _119 1
> 
> gambler=: 3 : 0
> out =. i.0
> max=. 0
> for_i. i. # y do.
> out=. out , ] max =. (0 >. max+ (i_index{y))
> end.
> )

Note: i and i_index are the same value here

>    gambler a
> 44 0 0 32 39 41 32 65 74 257 0 0 44 119 136 158 177 0 120 139 146 149
178 186 251 293 295 383 264 265
...
> I somehow guessed that a solution of the form f /\ a would exist, 
> but couldn't think of f.

   (0 >. +)/&.|.\ a

/ is right to left, but gambler uses left to right.  /(&.|.) is left
to right.

FYI,

-- 
Raul

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to