Created
August 19, 2021 06:54
-
-
Save yanfeng42/3e5dafdd262b808a1ca75f5f6c3425b5 to your computer and use it in GitHub Desktop.
2.1.3 有感: 在支持函数作为第一对象的语言里, 可以直接 使用 “过程” 定义 “数据”
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
(define (my-cons x y) | |
(lambda (m) | |
(cond ((= m 0) x) | |
((= m 1) y))) | |
) | |
(define (my-car z) (z 0)) | |
(define (my-cdr z) (z 1)) | |
; 100 | |
(my-car (my-cons 100 20)) | |
; 20 | |
(my-cdr (my-cons 100 20)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
技巧: 使用 函数 捕捉和记录 “变量”. 使用 函数本身 作为 “变量” 读写的 媒介.