Another hook,

   3 4 (-: |@j./)~ 5
1


On Mon, Mar 28, 2016 at 8:08 PM, Raul Miller <[email protected]> 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 3 4
> 1
>
> Thanks,
>
> --
> Raul
>
>
> On Mon, Mar 28, 2016 at 4:26 PM, Adam Tornhill <[email protected]>
> wrote:
> > 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 triangle. The solution was quick to code up:
> >
> > isRightTriangle =: (+/ @: *: @: [) = (*: @:])
> >
> > However, I'm left with a feeling that there must be a more elegant way.
> I set for a dyadic hook, but picking-out the left/right arguments like I do
> seems just wrong.
> >
> > I'd be happy for any tips and guidance on how one writes these kind of
> dyads in J.
> >
> > Thanks in advance!--
> > Homepage: www.adamtornhill.com
> > Twitter: @AdamTornhill
> >
> > Your Code as a Crime Scene:
> https://pragprog.com/book/atcrime/your-code-as-a-crime-scene
> > Lisp for the Web:  https://leanpub.com/lispweb
> > Patterns in C: https://leanpub.com/patternsinc
> > ----------------------------------------------------------------------
> > 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