Skip to content

Instantly share code, notes, and snippets.

@gregorykremler
Created December 25, 2014 05:30
Show Gist options
  • Save gregorykremler/68a72c4a3b7f6770daf0 to your computer and use it in GitHub Desktop.
Save gregorykremler/68a72c4a3b7f6770daf0 to your computer and use it in GitHub Desktop.
return of the map
# 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