Another thing you need to be aware of. J evaluates as much as it can when it executes a statement.
a=:0 a 0 add5=:(a=:2+3)+] a 5 add5 +-+-+-+ |5|+|]| +-+-+-+ a=:1 add5 3 8 a 1 add5 is defined by a tacit verb definition. But it evaluates all it can when defining add5. Here the 2+3 is replaced with a 5 and the assignment disappears. Not only that, but a is assigned a value when add5 is defined. Not when add5 runs. If you want a assigned when add5 runs, you have to defer the assignment of a as Dan's response shows. On Sat, Sep 14, 2013 at 11:26 AM, Dan Bron <[email protected]> wrote: > I wrote: > > a =: 2 +: :: 3: 0 > > will give 'a' the value 3 > > if +: raises an error, or 2 +: 3 otherwise > > Sorry, I meant "2+:0 otherwise" (if the dyadic domain of +: included > non-boolean integers). > > -Dan > > Please excuse typos; composed on a handheld device. > > On Sep 14, 2013, at 1:18 PM, Dan Bron <[email protected]> wrote: > > > a =: 2 +: :: 3: 0 > > > > Which will give a the value 3 (noun, not verb) if +: raises an error, or > 2 +: 3 otherwise > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
