Chapter 2, Building Abstractions with Data

Section - 2.3 Symbolic Data

Exercise 2.53


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
> (list 'a 'b 'c)
(mcons 'a (mcons 'b (mcons 'c '())))
; (a b c)
> (list (list 'george))
(mcons (mcons 'george '()) '())
; ((george))
> (cdr '((x1 x2) (y1 y2)))
(mcons (mcons 'y1 (mcons 'y2 '())) '())
; ((y1 y2))
> (cadr '((x1 x2) (y1 y2)))
(mcons 'y1 (mcons 'y2 '()))
; (y1 y2)
> (pair? (car '(a short list)))
#f
; false
> (memq 'red '((red shoes) (blue socks)))
#f
; false
> (memq 'red '(red shoes blue socks))
(mcons 'red (mcons 'shoes (mcons 'blue (mcons 'socks '()))))
; (red shoes blue socks)
>