What do you mean by "misbehave"? Note that the original specification was that adv behaves like this:
1 0 1 +: adv 2;'a'; 3 4 1 6 This takes a boxed argument and produces a numeric result. The implication is that a 1 in the left argument corresponds to unboxing the corresponding element in the right argument and doubling it. Another implication is that a 0 in the left argument corresponds to some other operation which produces the value 1. Note that coding by example (and specifying by example) works well enough, only if you are willing to live with whatever you get. And, sometimes you need to push back on that. -- Raul On Fri, Mar 28, 2014 at 4:47 AM, Brian Schott <[email protected]>wrote: > Raul, > > Your adv is really slick but I think it misbehaves with a numeric value > coinciding with zero. I have suggested a variation. > > > adv=: (@])(1:`)(@.[)(&>) > > 1 0 1 +: adv 2;'a'; 3 > > 4 1 6 > > 1 0 1 +: adv 2;2; 3 > > 4 1 6 > > adv=: (@])(]`)(@.[)(&>) > > 1 0 1 +: adv 2;2; 3 > > 4 2 6 > > > On Thu, Mar 27, 2014 at 10:32 PM, Raul Miller <[email protected]> > wrote: > > > Or: > > > > adv=: (@])(1:`)(@.[)(&>) > > +:adv > > 1:`(+:@])@.[&> > > 1 0 1 +: adv 2;'a'; 3 > > 4 1 6 > > > > Thanks, > > > > -- > > Raul > > > > > > > -- > (B=) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
