Re: [Jprogramming] Writing a dyadic verb

2016-03-29 Thread Jose Mario Quintana
Another hook, 3 4 (-: |@j./)~ 5 1 On Mon, Mar 28, 2016 at 8:08 PM, Raul Miller wrote: >5 -: +/&.:*: 3 4 > 1 >5 (-: +/&.:*:) 3 4 > 1 >isRightTriange=: (-: +/&.:*:)~ >3 4 isRightTriangle 5 > 1 > > Or, if you didn't mind using the other order, >isrt=: -: +/&.:*: >5 isrt

Re: [Jprogramming] Writing a dyadic verb

2016-03-28 Thread Raul Miller
5 -: +/&.:*: 3 4 1 5 (-: +/&.:*:) 3 4 1 isRightTriange=: (-: +/&.:*:)~ 3 4 isRightTriangle 5 1 Or, if you didn't mind using the other order, isrt=: -: +/&.:*: 5 isrt 3 4 1 Thanks, -- Raul On Mon, Mar 28, 2016 at 4:26 PM, Adam Tornhill wrote: > I'm moving on to learn J and t

Re: [Jprogramming] Writing a dyadic verb

2016-03-28 Thread Ric Sherlock
One option is to use a dyadic hook (rather than 5 (= +/)&:*: 3 4 If you want to use the same argument order as before: 3 4 (= +/)&:*:~ 5 Another option would be not to separate the triangle sides: isRightTri=: ({: = +/@:}:)@:*:@/:~"1 isRightTri 3 4 5 , 5 9 6 ,: 5 16 20 1 0 0 On Tue, Mar 29,

Re: [Jprogramming] Writing a dyadic verb

2016-03-28 Thread Don Guinn
When the same thing needs to be done to both the left and right arguments & and similar conjunctions can do the job. isRightTriangle =: =/&([:+/*:) 3 4 isRightTriangle 5 1 On Mon, Mar 28, 2016 at 2:26 PM, Adam Tornhill wrote: > I'm moving on to learn J and try to get some practical exerci

[Jprogramming] Writing a dyadic verb

2016-03-28 Thread Adam Tornhill
I'm moving on to learn J and try to get some practical exercise by working though problems from the Dyalog APL competition. One of the simpler problems is to write a verb that determines if the given legs of a triangle (left argument) and its hypotenuse (right argument) represent a right triang