summaryrefslogtreecommitdiff
path: root/pypers/oxford/lazy.txt
blob: 7db1f7c64b3b1ae781319a88a37bc4a32903fb9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
>>> import itertools
>>> def anyTrue(predicate, iterable): 
...     return True in itertools.imap(predicate, iterable)

>>> def is3(i):
...     print "i=%s" % i
...     return i == 3

>>> anyTrue(is3, range(10))
i=0
i=1
i=2
i=3
True