Created
April 20, 2012 14:40
-
-
Save henrik-ch/2429157 to your computer and use it in GitHub Desktop.
Haskell list comprehensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- [output function | generators/predicates] | |
-- like this | |
[ x * 2| x <- [1..4]] | |
-- can be read as take x and multiply it with two, and get x from the list consisting of 1 to 4. | |
-- [2,4,6,8] | |
-- or like this | |
[ (x * 2, y - 3)| x <- [1..3], y <- [2..4]] | |
--[(2,-1),(2,0),(2,1),(4,-1),(4,0),(4,1),(6,-1),(6,0),(6,1)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment