Something I indeed picked up along the way.  Though I learned more from your 
example.  One of the features of the verb:

assign_z_ =: 4 : '(x) =: y'


is that it delays that evaluation.





----- Original Message -----
From: Don Guinn <[email protected]>
To: General forum <[email protected]>
Cc: 
Sent: Saturday, September 14, 2013 2:11:49 PM
Subject: Re: [Jgeneral] :: (adverse) weirdness -- was Bug in adverb define

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

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to