Python Tutorial Was: Guido's regrets: filter and map

Lulu of the Lotus-Eaters mertz at gnosis.cx
Wed Nov 27 02:29:58 EST 2002


||And it doesn't replace reduce at all -- we've yet to see a construct
||proposed to do that (aside from writing it out as an explicit loop).

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]

Yours, Lulu...

--
mertz@  | The specter of free information is haunting the `Net!  All the
gnosis  | powers of IP- and crypto-tyranny have entered into an unholy
.cx     | alliance...ideas have nothing to lose but their chains.  Unite
        | against "intellectual property" and anti-privacy regimes!
-------------------------------------------------------------------------





More information about the Python-list mailing list