Thanks, works perfectly! Now I'll have a good think and try to understand
how this works ;-)

On Sun, Aug 16, 2020 at 10:02 PM Roger Hui <[email protected]>
wrote:

> If "operator" is >: there is a very easy solution:
>
>    desired_result -: operand + bitmask
> 1
>
> For a general monadic function, you can do as follows:
>
>    desired_result -: bitmask 0&(] operator)"0 operand
> 1
>
> The basic idea is what the power operator does; m&v or v&m allows you to do
> the same when the bitmask is an array and not a scalar.
>
>
>
>
> On Sun, Aug 16, 2020 at 12:45 PM Raoul Schorer <[email protected]>
> wrote:
>
> > Hi,
> >
> > This seems pretty trivial, but I'm stuck on how to perform conditional
> > application of a verb on a multidimensional array as defined by a bitmask
> > of the same shape as the operand array. Is there a typical idiom for
> that?
> >
> > For example,
> >
> > operand =. 2 2 2 $ 3 2 2 3 2 3 3 2
> >
> > bitmask =. 2 2 2 $ 1 0 0 1 0 1 1 0
> >
> > operator =. >:
> >
> > desired_result =. 2 2 2 $ 4 2 2 4 2 4 4 2
> >
> >
> > I tried looking at the doc, but I wasn't able to formulate a nice
> solution.
> >
> >
> > Thanks!
> >
> > Raoul
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> 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