The sentence  2  +&+&+: 3 expands to (+ +: 2) + (+ +: 3) . This might be 
clearer if we used 3 distinct verbs: x f&g&h y is (g h x) f (g h y) .

In f&g, f  retains the valence of the whole verb (is ambivalent), and g is 
always called monadically. By contrast, in f@g, f is always called monadically, 
while g retains the valence of the whole verb (is ambivalent). *

expression | monad (exp y) | dyad (x exp y)
f&g   |   f g y   |   (g x) f (g y)
f@g   | f g y   |   f (x g y)

(All subject to the rank of g; the rank-independent analogs are &: and @: 
respectively).

-Dan

* Note that The symmetry is not perfect: in f&g, g could be called at most 
twice, if the whole verb is called dyadically (and g is applied monadically the 
the right argument and again monadically to the left argument), whereas in f@g, 
f will be called exactly once (monadically to the result of g, whether g itself 
was called monadically or dyadically; in short, the asymmetry mirrors the 
asymmetry of dyads, which take 2 inputs but produce 1 output).

Sent from my iPhone

> On Mar 2, 2014, at 10:33 AM, Pascal Jasmin <[email protected]> wrote:
> 
> That is indeed the problem, but the code
> 
>  2  +&+&+: 3
> 
> 
> is not    2 + 2 +&+: 3
> 
> but rather
>    0 + 2 +&+: 3
> 10
> when it should be:
>     + 2 +&+: 3
> 10
> 
> There doesn't seem to be a good reason to insert 0 v in it.  This is weird 
> though:
> 
>      2 ([: +: ])&(+&+:) 3
> 12
> 
> I don't think it is:
> 
>  2+  2 +&+:3
> 
> which seems to have nothing to do with supplied verbs. So more likely:
> 
> +: (+ +: 3)
> 
> and x argument is discarded completely. (it should have applied to 2 +&+: 3, 
> and above result should be 20)
> 
> 
> ----- Original Message -----
> From: Don Guinn <[email protected]>
> To: Programming forum <[email protected]>
> Cc: 
> Sent: Sunday, March 2, 2014 10:02:31 AM
> Subject: Re: [Jprogramming] bug in & ?
> 
> I think the problem is that the left-most +: is not-or and only accepts
> boolean arguments.
> 
>    0 +:&+&+: 0
> 1
> 
> 
> 
> On Sun, Mar 2, 2014 at 7:53 AM, Pascal Jasmin <[email protected]>wrote:
> 
>>      +:&+&+: 3
>> 12
>>     2  +&+&+: 3
>> 10
>> 
>> 
>>   2  +:&+&+: 3
>> |domain error
>> |   2    +:&+&+:3
>> 
>> 
>> The 3rd verb (leftmost) is called dyadically (with 0 element? like /?)
>> even though it sees only a monadic expression.
>> ----------------------------------------------------------------------
>> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to