lambda (and reduce) are valuable

David Isaac aisaac0 at
Mon Dec 12 06:45:57 CET 2005

> Alan Isaac wrote:
> >>> #evaluate polynomial (coefs) at x using Horner's rule
> >>> def horner(coefs,x): return reduce(lambda a1,a2: a1*x+a2,coefs)
> > It just cannot get simpler or more expressive.

"Peter Otten" <__peter__ at> wrote in message
news:dne702$j1q$02$1 at
> But is it correct?


> Are we merely employing different conventions for the order of
> or is that simple and expressive lambda/reduce stuff obscuring an error?

It is too simple and expressive to obscure an error.   ;-)
This is particularly important since coefficient order is not standardized
across uses.

Alan Isaac

More information about the Python-list mailing list