> or is it... hmmm... but if % was exectured monadically twice, I
> would have expected the answer 7.
> 3 (* + [: % ] + [: % ]) 2
> 6.4
Or, equivalently, why doesn't the following
3 ([: % ] + [: % ]) 2
0.4
give 1 instead of 0.4?
The answer is that forks associate to the right, so that
([: % ] + [: % ]) is equivalent to [: % (] + ([: % ]))
You can see this by turning on the box, tree, or parens
forms of function display: Edit|Configure|Display .
In contrast:
3 (([: % ]) + [: % ]) 2
1
3 (* + ([: % ]) + [: % ]) 2
7
----- Original Message -----
From: Steven Taylor <[email protected]>
Date: Tuesday, March 17, 2009 5:08
Subject: Re: [Jprogramming] every box, take and ammend
To: Programming forum <[email protected]>
> So instead of x (* + %@:]) y <-----> x * y + x % y
>
> we get x (* + %@:]) y <-----> x * y + % x ] y
>
> So in a sense, when ] is rightmost it steals the chance to fork,
> and % is
> locked to monad due to the verb verb combination?
>
> BTW:
>
> this was exactly the sort of thing I was looking for...
> 3 (* + [: % ]) 2
>
>
> or is it... hmmm... but if % was exectured monadically twice, I
> would have
> expected the answer 7.
> 3 (* + [: % ] + [: % ]) 2
> 6.4
>
> Looks like I need more insight into 'context' and 'J
> parsing'. I can
> religiously avoid constructs like this and be content to be a poorer
> being/scripter/oo/procedural person. I thought I was on
> the cusp of fully
> understanding verb trains, forks, and hooks..
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm