(define (accumulate op initial sequence)
(if (null? sequence)
initial
(op (car sequence)
(accumulate op initial (cdr sequence)))))
(define (horner-eval x coefficient-sequence)
(accumulate (lambda (this-coeff higher-coeff) (+ this-coeff (* x higher-coeff)))
0
coefficient-sequence))
(horner-eval 2 (list 1 3 0 5 0 1))
SICP 练习2.34 多项式求值(horner规则)
最新推荐文章于 2023-01-13 22:47:05 发布