
Guido:
I probably missed it in this monster of a thread, but how do generator expressions do this? It seems that they'd only make reduce more efficient, but it would still be just as needed as before.
All we need is more standard accumulator functions like sum(). There are many useful accumulator functions that aren't easily expressed as a binary operator but are easily done with an explicit iterator argument, so I am hopeful that the need for reduce will disappear.
But this would still be true even if we introduced such functions *without* generator expressions, i.e. given some new standard accumulator foo_accumulator which accumulates using foo_function, you can write r = foo_accumulator(some_seq) instead of r = reduce(foo_function, some_seq) regardless of whether some_seq is a regular list or a generator expression. So it seems to me that generator expressions have *no* effect on the need or otherwise for reduce, and any suggestion to that effect should be removed from the PEP as misleading and confusing. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg@cosc.canterbury.ac.nz +--------------------------------------+