Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Data Represented as a Different Procedure
; 2.5
(define expt (** a b))
(define (2.5-cons a b)
(* (expt 2 a) (expt 3 b))
)
(define (2.5-car product)
(if (= 0 (remainder product 2))
(+ 1 (2.5-car (/ product 2)))
0)
)
(define (2.5-cdr product)
(if (= 0 (remainder product 3))
(+ 1 (2.5-cdr (/ product 3)))
0)
)
(define example (2.5-cons 5 7)) ; 69984
(2.5-car example) ; 5
(2.5-cdr example) ; 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.