Idris2/tests/node/node002/Pythag.idr

10 lines
312 B
Idris
Raw Normal View History

2020-06-12 23:35:08 +03:00
range : Integer -> Integer -> List Integer
range bottom top
= if bottom > top then []
else bottom :: range (bottom + 1) top
pythag : Integer -> List (Integer, Integer, Integer)
pythag top
= [(x, y, z) | z <- range 1 top, y <- range 1 z, x <- range 1 y,
x * x + y * y == z * z]