-
Notifications
You must be signed in to change notification settings - Fork 0
/
232.rkt
58 lines (53 loc) · 1.56 KB
/
232.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-beginner-abbr-reader.ss" "lang")((modname 232ex) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
;; Exercise 232
;; ------------
;; Eliminate quasiquote and unquote from the following expressions so that they
;; are written with list instead:
;;
;; `(1 "a" 2 #false 3 "c")
;;
;; this table-like shape:
;;
;; `(("alan" ,(* 2 500))
;; ("barb" 2000)
;; (,(string-append "carl" " , the great") 1500)
;; ("dawn" 2300))
;;
;; and this second web page:
;;
;; `(html
;; (head
;; (title ,title))
;; (body
;; (h1 ,title)
;; (p "A second web page")))
;;
;; where (define title "ratings")
;;
;; Also write down the nested lists that the expressions produce.
;; -----------------------------------------------------------------------------
`(1 "a" 2 #false 3 "c")
; ==
(list 1 "a" 2 #false 3 "c")
`(("alan" ,(* 2 500))
("barb" 2000)
(,(string-append "carl" " , the great") 1500)
("dawn" 2300))
; ==
(list (list "alan" (* 2 500))
(list "barb" 2000)
(list (string-append "carl" " , the great") 1500)
(list "dawn" 2300))
(define title "ratings")
`(html
(head
(title ,title))
(body
(h1 ,title)
(p "A second web page")))
; ==
(list 'html
(list 'head (list 'title "ratings"))
(list 'body (list 'h1 "ratings") (list 'p "A second web page")))