List comprehensions: Difference between revisions
→{{header|Haskell}}: (pure and empty in lieu of return and mzero)
(→{{header|Haskell}}: (pure and empty in lieu of return and mzero)) |
|||
Line 835:
and both of the above could be de-sugared to:
<lang haskell>import Control.
pyth :: Int -> [(Int, Int, Int)]
Line 845:
[y .. n] >>=
\z ->
case (((x ^ 2) + (y ^ 2)) == (z ^ 2)) of
True ->
False ->
which can be further specialised (given the particular context of the list monad, in which >>= is concatMap, pure is flip (:) [], and empty is []) to:
<lang haskell>pyth :: Int -> [(Int, Int, Int)]
|