小保哥

博客园 首页 新随笔 联系 订阅 管理

(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-terms)
                (+ this-coeff
                   (* higher-terms x)))
              0
              coefficient-sequence))

posted on 2013-05-10 21:28  小保哥  阅读(288)  评论(0)    收藏  举报