Skip to content

Instantly share code, notes, and snippets.

@jeamland
Created November 14, 2012 00:33
Show Gist options
  • Save jeamland/4069388 to your computer and use it in GitHub Desktop.
Save jeamland/4069388 to your computer and use it in GitHub Desktop.
import itertools
def is_odd(val):
print "Checking", str(val)
return bool(val % 2)
print "Using map..."
print any(map(is_odd, range(0, 10)))
print "\nUsing itertools.imap..."
print any(itertools.imap(is_odd, range(0, 10)))
print "\nUsing generator expression..."
print any(is_odd(foo) for foo in range(0, 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment