You could simplify (and generalize) this by replacing "[=&1" with "[", e.g.
1 0 1 0 0 1 1 0 ( (3-~]) ` (2*]) @. [ )"0 0] i.8 0 _2 4 0 1 10 12 4 1 2 2 0 2 2 1 0 ( (3-~]) ` (2*]) ` %: @. [ )"0 0] i.8 0 1 1.41421 0 2 2.23607 12 4 On 3/5/08, Arie Groeneveld <[EMAIL PROTECTED]> wrote: > > u=: [EMAIL PROTECTED] > v=: %:@] > > 0 1 0 0 1 ([EMAIL PROTECTED]([=&1))"0 0 [ 1 2 3 4 5 > 0 1.414213562 1.098612289 1.386294361 2.236067977 > > =@@i > > L.Tomei schreef: > > > I have an array y, an array of booleans x (same shape of y), and two > monadic > > verbs u and v. > > How can I apply verb u to each atom of y when corresponding value of x > is 0, > > and verb v when corresponding value of x is 1? > > Thank you. > > > > L.Tomei > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
