|
|
| functional python |
Posted 2006-08-10 03:54:03 by
Jim Crawford
To those complaining about the planned removal of reduce() from Python, I have four lines of code for you:
def reduce(func, seq):
result = seq[0]
for elem in seq[1:]: result = func(result, elem)
return result
lambda is a bit harder to replace, admittedly, but I don't think naming your one-off functions is too egregious a requirement.
|
|
| what's this? | | This is Jim Crawford's blog. Details and contact information
here.
|
|