Question regarding a recent article on informit.com
Peter Hansen
peter at engcorp.com
Thu Mar 20 08:34:48 EST 2003
Ben S wrote:
>
> Are there any good tutorials of examples of list comprehension use? In
> particular, I'm interested in how to replicate the functionality of
> reduce? Map and filter seem easy to do, though.
Doesn't reduce return a non-list (or at least, isn't it the case that
it doesn't necessarily return a list the way map and filter do)?
An *abuse* of a list comprehension, or a list comprehension in
conjuction with something else, could probably replicate reduce(),
but why bother? reduce() isn't really like map and filter.
-Peter
More information about the Python-list
mailing list