Skip to content

Instantly share code, notes, and snippets.

@yao2030
Created December 12, 2012 08:29
Show Gist options
  • Save yao2030/4266090 to your computer and use it in GitHub Desktop.
Save yao2030/4266090 to your computer and use it in GitHub Desktop.
;;
(define (accumulate op init seq)
(if (null? seq)
init
(op (car seq)
(accumulate op init (cdr seq)))))
;;
(define (accumulate-n op init seqs)
(if (null? (car seqs))
'()
(cons (accumulate op init (map car seqs))
(accumulate-n op init (map cdr seqs)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment