[Python-3000] what do I use in place of reduce?

Nicholas T ntung at ntung.com
Wed Apr 23 22:56:57 CEST 2008


Hi all,

   It's obvious how to use LC's to replace map and filter, but what about
reduce? It is one of my favorite functions.

>>> time=1901248
>>> reduce(lambda a, b: a[:-1] + [a[-1]%b, math.floor(a[-1]/b)], [[time],
60, 60, 24])
[28, 7.0, 0.0, 22.0] # secs, mins, hrs, days

Nicholas

-- 
http://ntung.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-3000/attachments/20080423/60f9c6b5/attachment.htm>


More information about the Python-3000 mailing list