List comprehensions: Difference between revisions
→{{header|Haskell}}: Replaced a red link with an external link to the Haskell Wiki.
(add Tcl) |
Underscore (talk | contribs) (→{{header|Haskell}}: Replaced a red link with an external link to the Haskell Wiki.) |
||
Line 88:
=={{header|Haskell}}==
Since lists are [
▲ pyth n = [(x,y,z) | x <- [1..n], y <- [x..n], z <- [y..n], x^2 + y^2 == z^2]
▲Since lists are [[Monads]], one can alternatively also use the do-notation (which is practical if the comprehension is large):
▲ import Control.Monad
y <- [x..n]
▲ pyth n = do
guard $ x^2 + y^2
▲ z <- [y..n]
▲ return (x,y,z)
=={{header|Mathematica}}==
|