Jump to content

List comprehensions: Difference between revisions

→‎{{header|Haskell}}: Used mzero rather than [] in immediate desugaring
(→‎{{header|AppleScript}}: Updated primitives)
(→‎{{header|Haskell}}: Used mzero rather than [] in immediate desugaring)
Line 835:
 
and both of the above could be de-sugared to:
<lang haskell>pythimport ::Control.Monad Int -> [(Int, Int, Intmzero)]
 
pyth :: Int -> [(Int, Int, Int)]
pyth n =
[1 .. n] >>=
Line 845 ⟶ 847:
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.