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