Can this be written more concisely in a functional style
jcb at iteris.com
Tue Nov 18 19:52:58 CET 2003
My intention was that test() return True or False.
So True in itertools.imap(test, xs) is what I was looking for.
I also like the any() function suggested above.
def any(p, seq):
"""Returns true if any element in seq satisfies predicate p."""
for elt in itertools.ifilter(p, seq):
In the itertools.imap version does
<True in> test against a continually growing list, ie.
True in [False]
True in [False, False]
True in [False, False, False]
True in [False, False, False, True]
or does it just apply <in> to the next generated element.
Is the itertools.imap version as efficient as the for loop version?
More information about the Python-list