您的位置:首页 > 其它

SICP 练习2.34 多项式求值(horner规则)

2016-06-24 16:13 417 查看
(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))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: