Horner's rule for polynomial evaluation: Difference between revisions

→‎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)
Anonymous user