Anonymous user
List comprehensions: Difference between revisions
→{{header|Haskell}}: List-comprehension is just sugar for do-notation.
(→{{header|Haskell}}: List-comprehension is just sugar for do-notation.) |
|||
Line 810:
<lang haskell>pyth n = [(x,y,z) | x <- [1..n], y <- [x..n], z <- [y..n], x^2 + y^2 == z^2]</lang>
List-comprehensions in Haskell are in fact syntactic sugar for do-notation, so the above is equivalent to the following:
<lang haskell>import Control.Monad
|