Skip to content

Instantly share code, notes, and snippets.

@yakreved
Created August 13, 2013 07:21
Show Gist options
  • Save yakreved/6218641 to your computer and use it in GitHub Desktop.
Save yakreved/6218641 to your computer and use it in GitHub Desktop.
sicp 2.5
(define (cons x y)
(* (expt 2 x) (expt 3 y)))
(define (factor base value)
(define (factor-iter value counter)
(if (= (remainder value base) 0)
(factor-iter (/ value base) (+ counter 1))
counter))
(factor-iter value 0))
(define (car pair)
(factor 2 pair))
(define (cdr pair)
(factor 3 pair))
(cons 1 2)
(car (cons 1 2))
(car (cons 3 5))
(cdr (cons 1 2))
(cdr (cons 3 5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment