Is there a way of making map lazy? Or is there another implementation of it built-in in Python?
I want something like this to work:
from itertools import count
for x in map(lambda x: x**2, count()):
print x
Of course, the above code won't end, but I'd like just to enter any condition (or more complex logic) inside the for and stop at some point.
x*2instead ofx**2, the blog is pretty much perfectly tailored to this question!