Harmonic series: Difference between revisions

Content added Content deleted
(Remove unwanted and unnecessary white space from task header. Makes it look like crap on mobile browsers.)
(→‎{{header|Python}}: Functor law tweak to eliminate lambda)
Line 877: Line 877:
from fractions import Fraction
from fractions import Fraction
from itertools import accumulate, count, islice
from itertools import accumulate, count, islice
from operator import add




Line 885: Line 886:
'''
'''
return accumulate(
return accumulate(
map(Fraction, count(1)),
(1 / Fraction(x) for x in count(1)),
lambda a, x: a + 1 / x
add
)
)