Python Tutorial Was: Guido's regrets: filter and map
Bernhard Herzog
bh at intevation.de
Wed Nov 27 05:19:29 EST 2002
Lulu of the Lotus-Eaters <mertz at gnosis.cx> writes:
> Actually... here's an... ummm... "improved" version:
>
> reduce = lambda func, seq, init=None:\
> [(l.append(func(l[i],seq[i])),l[-1])
> for l in [[init or seq[0]]]
> for i in range(len(seq))][-1][1]
It doesn't work correctly:
>>> import operator
>>> reduce(operator.add, [1,2])
4
That should have been 3.
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
MapIt! http://www.mapit.de/
More information about the Python-list
mailing list