by fireflies_ · 7y ago · 0 comments
Admittedly Python's facilities for doing that with some mutable state are pretty nice:
from itertools import islice
def fib():
a, b = 0, 1
while True:
yield a
a, b = b, a + b
list(islice(fib(), 10)) == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]I was speaking to readability.