Insert, an adverb, consumes the entire verb its left.
The entire verb left of / is  =&0@:+
Hence parenthesize the verbs.

   coprime =. =&0@:(+/)@:(e.&q:)
   5 coprime 6
1

Date: Sun, 15 Jun 2014 12:49:48 +0100
From: Jon Hough<[email protected]>
To:"[email protected]"  <[email protected]>
Subject: [Jprogramming] Coprime Dyadic Verb
Message-ID:<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

My attempt at a coprime dyadic verb, which returns 1 for coprime integers and 0 
otherwise seems to not work. I do not understand why this verb fails.
coprime =. =&0@:+/@:(e.&q:)
5 coprime 6
returns 0.
My understanding is thus:
Verb is read right to left.First :
5 (e.&q:) 6

is evaluated. This equates to (q: 5) e. (q: 6). (which gives 0)
Next +/ acts monadically on this result.

Finally we compare the result with 0.

So my understanding is 5 coprime 6 should return 1.
Regards.

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

Reply via email to