Exercise 1.4.19
Quoting
Another way to construct tree structure is using the quote
or '
.
* (quote (1 2 3))
(1 2 3)
* '(1 2 3)
(1 2 3)
* (list 1 2 3)
(1 2 3)
The structures you create this way are equivalent.
* (equal (quote (1 2 3)) '(1 2 3))
T
* (equal '(1 2 3) (list 1 2 3))
T
The difference is that, while list
essentially means "Return the list of these arguments", quote
/'
means "Return this argument without evaluating it".
* (defparameter *test* 2)
*test*
* (list 1 *test* 3)
(1 2 3)
* '(1 *test* 3)
(1 *test* 3)
* (list (+ 3 4) (+ 5 6) (+ 7 8))
(7 11 15)
* '((+ 3 4) (+ 5 6) (+ 7 8))
((+ 3 4) (+ 5 6) (+ 7 8))