Skip to content

Instantly share code, notes, and snippets.

@hidsh
Created February 1, 2012 06:27
Show Gist options
  • Save hidsh/1715483 to your computer and use it in GitHub Desktop.
Save hidsh/1715483 to your computer and use it in GitHub Desktop.
python: sample of fiter and lambda
def even(x):
return x % 2 == 0
l = range(0, 10)
print filter(even, l)
print filter(lambda x: x % 2, l) # odd()
# result
# [0, 2, 4, 6, 8]
# [1, 3, 5, 7, 9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment