Replace reduce with listcomprehension?
Diez B. Roggisch
deets at nospam.web.de
Mon Aug 25 18:38:57 EDT 2008
ssecorp schrieb:
> GvR wants to eliminate all the functional stuff (lambda map reduce
> filter) which kind of makes sense for Python, listcomprehensions are
> more efficient(at least as implemented inpython) from what i have
> gathered and they can express everything map/reduce/filter with
> crippled lambdas can.
>
> but what about this:
> reduce(lambda x,y:x*y+x,[1,2,3,4,5,6])
>
> how would I express that in a listcomprehension?
You can't. And AFAIK your are wrong - GvR doesn't wan to eliminate the
functional stuff.
http://www.artima.com/weblogs/viewpost.jsp?thread=98196
http://www.python.org/dev/peps/pep-3099/
Diez
More information about the Python-list
mailing list