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 ->
[x .. n] >>=
[x .. n] >>=
(\y ->
\y ->
[y .. n] >>=
[y .. n] >>=
(\z ->
\z ->
case x ^ 2 + y ^ 2 == z ^ 2 of
case (((x ^ 2) + (y ^ 2)) == (z ^ 2)) of
True -> return (x, y, z)
True -> return (x, y, z)
False -> mzero)))</lang>
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: