Anonymous user
Horner's rule for polynomial evaluation: Difference between revisions
Horner's rule for polynomial evaluation (view source)
Revision as of 15:50, 31 March 2010
, 14 years ago→Functional version: make it work for empty lists too
m (→{{header|Python}}: follows new pseudocode.) |
(→Functional version: make it work for empty lists too) |
||
Line 120:
>>> def horner(coeffs, x):
return reduce(lambda acc, c: acc * x + c, reversed(coeffs), 0)
>>> horner( (-19, 7, -4, 6), 3)
|