The basis of all Haskell love-hate relationships
Depends on what you think about this snippet of code:1
let square y = y * y; limit = 100 in [(x, y, z) | y <- [1..limit], x <- [1..y], z <- [1..limit], square x + square y == square z]
-
It finds all the right triangles with integer sides smaller than
limit
without duplicates. If you want the version with duplicates, just usex <- [1..limit]
↩︎