Created
December 25, 2014 05:30
-
-
Save gregorykremler/68a72c4a3b7f6770daf0 to your computer and use it in GitHub Desktop.
return of the map
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
# There are built-in higher order functions | |
map(add_10, [1, 2, 3]) # => [11, 12, 13] | |
filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7] | |
# We can use list comprehensions for nice maps and filters | |
[add_10(i) for i in [1, 2, 3]] # => [11, 12, 13] | |
[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment