SICP 习题2.36 accumulate-n的实现

(define (accumulate op initial sequence)
  (if (null? sequence)
    initial
    (op (car sequence)
        (accumulate op initial (cdr sequence)))))

(define (accumulate-n op init seqs)
  (if (null? (car seqs))
    '()
    (cons (accumulate op init (map (lambda (sub-seqs) (car sub-seqs)) seqs))
          (accumulate-n op init (map (lambda (sub-seqs) (cdr sub-seqs)) seqs)))))

你可能感兴趣的:(SICP)