Skip to content

Instantly share code, notes, and snippets.

@yao2030
Created December 12, 2012 07:04
Show Gist options
  • Save yao2030/4265708 to your computer and use it in GitHub Desktop.
Save yao2030/4265708 to your computer and use it in GitHub Desktop.
(define (map p sequence)
(accumulate (lambda (x y) (cons (p x) y)) '() sequence))
(define (append seq1 seq2)
(accumulate cons seq2 seq1))
;; it took me about half an hour to figure length out.
(define (length sequence)
(accumulate (lambda (x y) (+ 1 y)) 0 sequence))
@yao2030
Copy link
Author

yao2030 commented Dec 12, 2012

SICP 2.33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment