阅读背景:

1.32 (更高层次的抽象! 乘法与加法本来就是一回事)

来源:互联网 
(define (accumulate combiner null-value term a next b)
  (define (iter a result)
  (if (> a b)
      result
      (iter (next a)
            (combiner (term a) result))))
  (iter a null-value))

(define (sum term a next b)
  (accumulate +
              0
              term
              a
              next
              b))

(define (product term a next b)
  (accumulate *
              1
              term
              a
              next
              b))

(sum (lambda (x) x)
           1
           (lambda (i) (+ i 1))
           10)
(define (accumulate combiner null-value ter



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: