SICP_2.53-2.55

Posted lan126

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SICP_2.53-2.55相关的知识,希望对你有一定的参考价值。

 1 #lang racket
 2 
 3 ;;;;;;;;;;;;;;;;;;2.53
 4 (define (memq item x)
 5   (cond ((null? x) false)
 6         ((eq? item (car x)) x)
 7         (else (memq item (cdr x)))))
 8 
 9 (list a b c)
10 
11 (list (list george))
12 
13 (cdr ((x1 x2) (y1 y2)))
14 
15 (cadr ((x1 x2) (y1 y2)))
16 
17 (pair? (car (a short list)))
18 
19 (memq red ((red shoes) (blue socks)))
20 
21 (memq red (red shoes blue socks))
22 
23 ;;;;;;;;;;;;;;;2.54
24 (define (equal? a b)
25   (cond ((and (pair? a) (pair? b)
26               (equal? (car a) (car b))
27               (equal? (cdr a) (cdr b)))
28          true)
29         ((eq? a b) true)
30         (else false)))
31 
32 ;;;;;;;;;;;;;test
33 (equal? (this is a list) (this is a list))
34 
35 (equal? (this is a list) (this (is a) list))
36 
37 ;;;;;;;;;;;;;;2.55
38 (car ‘‘abracadara)
39 
40 (car (quoto abracadara))

"  ‘ " 相当于是单引号,只不过省略了后半引号

以上是关于SICP_2.53-2.55的主要内容,如果未能解决你的问题,请参考以下文章

SICP_3.25

SICP_3.27

SICP_3.24

SICP_3.26

SICP_3.7-3.8

SICP_2.21-2.23