Comments on Version 2, Draft Pep for Deprecating Builtins
David Eppstein
eppstein at ics.uci.edu
Mon Apr 29 16:04:52 EDT 2002
In article <Bhgz8.58769$vm6.9975333 at ruti.visi.com>,
grante at visi.com (Grant Edwards) wrote:
> > reduce doesn't return a list, so a list comprehension is not an
> > appropriate replacement.
> >
> > reduce(fn, seq, initial)
> > becomes:
> > res = initial
> > for v in seq: res = fn(res, v)
>
> I find the "reduce" spelling simpler and easier to both read
> and write.
Not to mention that the two parameter reduce (without the "initial"
argument) becomes a lot uglier...e.g. instead of
reduce(fn, seq)
we need something like
sseq = iter(seq)
res = sseq.next()
for v in sseq:
res = fn(res, v)
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list