Exercise 182: Eliminate quote from the following expressions
- '(1 "a" 2 #f 3 "c")
- '()
- and this table-like shape:
'(("alan" 1000) ("barb" 2000) ("carl" 1500) ("dawn" 2300))
Now eliminate list in favor of cons where needed.
Eliminate in favour of list
This is very straight forward.
(list 1 "a" 2 false 3 "c")
(list)
(list (list "alan" 1000)
(list "barb" 2000)
(list "carl" 1500)
(list "dawn" 3000))
Eliminate in favour of cons
This is not hard, but painful. Constructing lists like this is frustrating - which is the point of the exercise.
empty
(cons (cons "allan" (cons 1000 empty))
(cons (cons "barb" (cons 2000 empty))
(cons (cons "carl" (cons 1500 empty))
(cons (cons "dawn" (cons 3000 empty))
empty ))))