Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,23 +1,11 @@
'''Fibonacci accumulation'''
from itertools import islice
from itertools import accumulate
def fib():
yield 0
yield 1
a, b = fib(), fib()
next(b)
while True:
yield next(a)+next(b)
# fibs :: Integer :: [Integer]
def fibs(n):
'''An accumulation of the first n integers in
the Fibonacci series. The accumulator is a
pair of the two preceding numbers.
'''
return [
a
for a, b in accumulate(
range(1, n), # we don't actually use these numbers
lambda acc, _: (acc[1], sum(acc)),
initial = (0, 1)
)
]
# MAIN ---
if __name__ == '__main__':
print(f'First twenty: {fibs(20)}')
print(tuple(islice(fib(), 10)))