Depends on the verb.  In the case >:,

   a=: i. 20
   n=: 3
   a + 0=n|i.#a
1 1 2 4 4 5 7 7 8 10 10 11 13 13 14 16 16 17 19 19

Basically apply the verb or the identity function, depending on 0=n|i.#a .



On Wed, Jan 15, 2020 at 6:30 PM Skip Cave <s...@caveconsulting.com> wrote:

> How does one apply a monadic verb repetitively to every nth element of a
> one1-dimentional array?
>
> For example:
>
>    ]a=.i.20
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
>   n=.3
>
> NB. Design u to increment every nth integer in a:
>
>
>   u=.??:<??
>   n u a
> 1 1 2 4 4 5 7 7 8 10 10 11 13 13 14 16 16 17 19 19
> ----------------------------------------------------------------------
> 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