Skip to content

Instantly share code, notes, and snippets.

@jimmyp
Last active December 17, 2015 13:10
Show Gist options
  • Save jimmyp/5615209 to your computer and use it in GitHub Desktop.
Save jimmyp/5615209 to your computer and use it in GitHub Desktop.
SICP 1.2 Exercises
; ex 1.11
(define (f n)
(if ((n < 3) n)
(else (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (-n 3)))))))
; (f 4)
; (+ (f 3) (* 2 (f 2)) (* 3 (f 1)))
; (+ (+ (f 2) (* 2 (f 1)) (* 2 (f 0))) (* 2 2) (* 3 1))
; (+ (+ (f 2) (* 2 (f 1)) (* 2 (f 0))) 4 3)
; (+ (+ (f 2) (* 2 (f 1)) (* 2 (f 0))) 4 3)
; (+ (+ 2 (* 2 1) (* 2 0) ) )
; (+ (+ 2 (2) (0) ) 4 3)
; (+ 4 4 3)
; (11)
; ex 1.14
; (count-change 11)
; (cc 11 5)
; (+ (cc 11 4) (cc -39 5))
; (+ (+ (cc 11 3) (cc -14 4)) 0)
; (+ (+ (+ (cc 11 2) (cc 1 3)) 0) 0)
; (+ (+ (+ (+ (cc 11 1) (cc 6 2)) (+ (cc 1 2) (cc -9 3)))))
; ......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment