try:
coprime =. =&0@:(+/)@:(e.&q:)

the adverb / is greedy and will try and make the verb to the left as big as
possible. I.e. (=&0@:+)/ not just +/
You could also use:
coprime=: 0 = +/@:(e.&q:)


On Sun, Jun 15, 2014 at 11:49 PM, Jon Hough <[email protected]> wrote:

> 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
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to