Suppose I want to invert every 3rd binary bit, then every second bit where
f is -. (selective not):

]a=.20#1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

]b=.3 f a

0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1

]c .2 f b

1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1


How to define f?


Skip





On Wed, Jan 15, 2020 at 8: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

Reply via email to