exercise-36.scm (625B)
1 (define-library (sicp solutions chapter-2 exercise-36) 2 (import (scheme base)) 3 (import (sicp utils)) 4 (export accumulate-n) 5 6 (begin 7 (define (accumulate-n op init seqs) 8 ;; Took it out of exercise-2.36 because we'll need it later in 2.37. 9 (if (null? (car seqs)) 10 '() 11 (cons (accumulate op 12 init 13 (map (lambda (x) (car x)) 14 seqs)) 15 (accumulate-n op 16 init 17 (map (lambda (x) (cdr x)) 18 seqs)))))))