On Sun, May 11, 2014 at 5:08 PM, 'Pascal Jasmin' via Programming <[email protected]> wrote: > booltest =. (0<+./) *. 0<# > is designed to return 0 for 0 0 0 and i.0, and hopefully this: > booltest i.0 0, but: > > (i.0) -: booltest i.0 0 > 1 > > the problem with all of this is: > 3 : 'if. booltest i. 0 0 do. 1 else. 0 end.' 4 > 1 > > so, it appears I need a 3 part test? How would I write it?
booltest=: [: */ 0 = , You do not care about rank or shape, so the argument needs to be raveled. You want to test if values are zero, so that gives us 0 = , And you want to know if all of them are, so */ (or *./) combines them. The empty case gets the identity value for * (or *.) which happens to be what you want. Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
