Pythagoras’ Theorem In APL

Below is Pythagoras’ theorem interpreted into APL. To the left of the function simply enter a 2 element numeric vector for example 3 4 and to the right enter a scalar for example 10.

Pythagoras Theorum APL

A result of 1 means the triangle is right angled, a result of zero means it is not a right angled triangle.

The left vector represents the two shortest legs of the triangle and the right scalar represents the hypotenuse. Below are a couple of examples:

Pythag proof APL

Give it a try…