Functional ops on lists: where is FoldList?

Jason Orendorff jason at jorendorff.com
Tue Jan 22 16:02:47 EST 2002


David Eppstein wrote:
> If that's unclear, here's the simple-generator version of what I 
> mean, with the "x" argument to FoldList dropped for consistency
> with reduce() [...]

Actually, reduce has an optional third argument that gives an
initial value.

> I'm curious why this was omitted from Python's built-in 
> functional-programming repertoire.

Python's "functional-programming repertoire" is lacking in more
ways than just that.

> (This is a continuation of my efforts in using Python for my algorithms 
> class -- today's lecture includes counting sort, [...]  As it is,
> I will just do it in a loop, which will probably end up confusing
> the students less anyway.)

Well, then it's your students' good fortune that Python lacks
this function, I suppose.

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list