List comprehensions: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: Used mzero rather than [] in immediate desugaring) |
(→{{header|Haskell}}: Removed redundant brackets) |
||
Line 840: | Line 840: | ||
pyth n = |
pyth n = |
||
[1 .. n] >>= |
[1 .. n] >>= |
||
\x -> |
|||
[x .. n] >>= |
|||
\y -> |
|||
[y .. n] >>= |
|||
\z -> |
|||
case (((x ^ 2) + (y ^ 2)) == (z ^ 2)) of |
|||
True -> return (x, y, z) |
|||
False -> mzero</lang> |
|||
which can be further specialised (given the particular context of the list monad, in which >>= is concatMap) to: |
which can be further specialised (given the particular context of the list monad, in which >>= is concatMap) to: |