This would be the explicit version

addCycle =: 4 : 0
ret =. y
n=. (#y)
for_i. (i.x) do.
ret =. ret + (1 (n|i) } ((#y)#0))
end.
)




On Thu, Dec 7, 2017 at 9:48 AM, Joe Bogner <[email protected]> wrote:

> I'm still working on day 6 and I'm looking for a tip on a specific part
> I'm trying (not the whole solution)
>
> I'd like to define a verb that cycles through a list N times and adds 1 to
> each element
>
> 3 addCycle (4#0) -: 1 1 1 0
>
> 4 addCycle (4#0) -: 1 1 1 1
>
> 5 addCycle (4#0) -: 2 1 1 1
>
> 6 addCycle (4#0) -: 2 2 1 1
>
> 7 addCycle (4#0) -: 2 2 2 1
>
> I was initially messing around with variants of this (clearly wrong)
>
> ((1 (0) } ]) + |.)^:3 (0 0 0 0)
>
> I also wonder if there's some antibase pattern or odometer solution
>
> thanks
>
>
>
>
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to