Last active
November 2, 2019 21:15
-
-
Save chelseatroy/c848db246f46f673c91d0fc0fff2ba04 to your computer and use it in GitHub Desktop.
Data Represented as a Different Procedure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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