乐正

Actions speak louder than words.

Sicp-ex2-53

问题

解释器在求值下面各个表达式时将打印出什么?

1
2
3
4
5
6
7
8
9
10
11
12
13
(list 'a 'b 'c)

(list (list 'george))

(cdr '((x1 x2) (y1 y2)))

(cadr '((x1 x2) (y1 y2)))

(pair? (car '(a short list)))

(memq 'red '((red shoes) (blue socks)))

(memq 'red '(red shoes blue socks))

解答

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(list 'a 'b 'c)
;Value 13: (a b c)

(list (list 'george))
;Value 14: ((george))

(cdr '((x1 x2) (y1 y2)))
;Value 15: ((y1 y2))

(cadr '((x1 x2) (y1 y2)))
;Value 16: (y1 y2)

(pair? (car '(a short list)))
;Value: #f

(memq 'red '((red shoes) (blue socks)))
;Value: #t

(memq 'red '(red shoes blue socks))
;Value 18: (red shoes blue socks)

draft

« sicp-ex2-52 sicp-ex2-54 »

Comments