List comprehensions: Difference between revisions

Content added Content deleted
m (→‎{{header|Haskell}}: (>>=) is flip concatMap)
m (→‎{{header|Haskell}}: (white space adjustment))
Line 828: Line 828:
pyth :: Int -> [(Int, Int, Int)]
pyth :: Int -> [(Int, Int, Int)]
pyth n = do
pyth n = do
x <- [1..n]
x <- [1 .. n]
y <- [x..n]
y <- [x .. n]
z <- [y..n]
z <- [y .. n]
guard $ x^2 + y^2 == z^2
guard $ x ^ 2 + y ^ 2 == z ^ 2
return (x,y,z)</lang>
return (x, y, z)</lang>


and both of the above could be de-sugared to:
and both of the above could be de-sugared to: