Hi Jon,

Like so many things in J, an added character usually does make a difference. 
That is the cost of using less to say more. :)

In this case, I think that you have a pretty good handle on func1, so I will 
focus on what func2 is doing.

func2 is a hook which means that func2 5 is acting like 5((3&+) (2&-)) 5 
because hooks (u v) y are the same as y( u v) y which is the same as y u ( v y)

 In your case func2 5 is like 5 (3&+) ((2&-) 5)  same as 5 (3&+) _3 . This is 
where things change up a bit because you are asking (3&+) to be executed on _3 
a total of 5 times. In other  words add 3 to _3 five times and you have 15+_3 
which is 12

I see Ian has already given some good links for further reading. It does seem 
confusing at first, but it is consistent and does let you do some remarkable 
things when you get a feel for it.

Cheers, bob

On Apr 30, 2014, at 8:42 AM, Jon Hough <[email protected]> wrote:

> I can't understand why
> func1 =. 3&+ @: (2&-)
> func2 =. (3&+) (2&-)
> 
> give different results as mondaic verbs.
> func1 5 gives 0, which is what I would expect.
> func2 5 gives 12, which I can't understand.
> I would like to know what the difference is between func1 and func2. It is my 
> understanding that for monadic verbs @: is optional, so doesn't add anything 
> to the meaning of the whole verb.
> Regards.                                        
> ----------------------------------------------------------------------
> 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