Jump to content

List comprehensions: Difference between revisions

→‎{{header|Haskell}}: Removed redundant brackets
(→‎{{header|Haskell}}: Used mzero rather than [] in immediate desugaring)
(→‎{{header|Haskell}}: Removed redundant brackets)
Line 840:
pyth 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:
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.