thank you for your explanations dan,

double =: 3 : 0
+: y
:
smoutput x
+: y
)


   2 (double &+)&+: 3
4
12

   2 double &(+&+:) 3
4
12

this I understand
   4 (double &+) 6
4
12

and this
    (double &+) 6
12

so this feels like a bug:

   2 double &(+&+:) 3
4
12

 should be able to parenthesize to force monad.  Though I get what is happening 
to a slight degree, its extremely unusual that x gets modified.

----- Original Message -----
From: Dan Bron <j...@bron.us>
To: "programm...@jsoftware.com" <programm...@jsoftware.com>
Cc: 
Sent: Sunday, March 2, 2014 1:59:14 PM
Subject: Re: [Jprogramming] bug in & ?

Looking at that table, it's clear that the monadic cases of @ and & are 
identical, so the difference lies in how they combine dyadic verbs. So maybe a 
simpler or more intuitive way to express the difference is: @ expresses that 
you want x and y to "meet" _first_, and & expresses you want x and y to meet 
last.

I think this definition will allow us to understand expressions like yours more 
intuitively. Rather think of grammar and precedence and rules of substitution, 
we just note that +:&+&+: is composed solely with &, so the combination of x 
and y will be deferred to the very end, pushed to the leftmost verb; therefore 
that +: will be called dyadically, and since dyad +: has a Boolean domain (both 
left and right), it will raise a domain error when invoked with integers (4 and 
6 in this case).

Sent from my iPhone


> On Mar 2, 2014, at 10:59 AM, Dan Bron <j@bron. That tablus> wrote:
> 
> 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 <godspiral2...@yahoo.ca> 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
----------------------------------------------------------------------
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