Bits are a domain where identity values tend to be easy to find.

And, of course, the approach Roger Hui mentioned works great for this example:

Operation:  ~:
Identity value: 0
Mask: 0=3|i.@#

   a=:20#1
   (~: 0=3|i.@#) a
0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1

FYI,

-- 
Raul

On Thu, Jan 16, 2020 at 1:30 AM Skip Cave <[email protected]> wrote:
>
> 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 <[email protected]> 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