Python Tutorial Was: Guido's regrets: filter and map
Anton Vredegoor
anton at vredegoor.doge.nl
Tue Nov 26 05:47:59 EST 2002
On Mon, 25 Nov 2002 23:19:46 -0800, Terry Hancock
<hancock at anansispaceworks.com> wrote:
>map(), filter(), and reduce() do not represent all of the uses for filter,
>and thus, they can't all be replaced by list comps (BTW, I never used
>reduce, never understood what it was good for, and don't immediately
>see how it can be done using list-comps -- would be genuinely interested
>in seeing a couple of example if anyone's willing).
from operator import mul
def fac(n):
#faculty of n
return reduce(mul,range(2,n+1),1L)
Regards,
Anton.
---
2658271574788448768043625811014615890319638528000000000L
More information about the Python-list
mailing list