I am studying Clojure and I have found a solution to find the problem of a regular triangle in a Haskell book using list comprehension so that the problem is solved neatly:
Finding the Right Triangle
The lengths of the three sides are integers.
Each side is less than or equal to 10.
Along the perimeter of the triangles (the sum of the lateral lengths) is 24.
In Haskell:
ghci> let rightTriangles' = [ (a,b,c) | c <- [1..10], a <- [1..c], b <- [1..a], a^2 + b^2 == c^2, a+b+c == 24] ghci> rightTriangles' [(6,8,10)]
Is there such an elegant list comprehension solution in Clojure?
source share