Created
January 26, 2014 03:12
-
-
Save rgm/8627828 to your computer and use it in GitHub Desktop.
SICP lecture 5B 55m00s -> end
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
| ;; pure smoke immutable cons | |
| (define cons | |
| (lambda (x y) | |
| (lambda (m) (m x y)))) | |
| (define car | |
| (lambda (x) | |
| (x (lambda (a d) a)))) | |
| (define cdr | |
| (lambda (x) | |
| (x (lambda (a d) d)))) |
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
| ;; pure smoke mutable cons | |
| (define cons | |
| (lambda (x y) | |
| (lambda (m) | |
| (m x | |
| y | |
| (lambda (n) (set! x n)) | |
| (lambda (n) (set! y n)))))) | |
| (define car | |
| (lambda (x) | |
| (x (lambda (a d sa sd) a)))) | |
| (define cdr | |
| (lambda (x) | |
| (x (lambda (a d sa sd) d)))) | |
| (define set-car! | |
| (lambda (x y) | |
| (x (lambda (a d sa sd) (sa y))))) | |
| (define set-cdr! | |
| (lambda (x y) | |
| (x (lambda (a d sa sd) (sd y))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment