Reputation: 355
The length of
(length (car '('(0)'(1 2 3)'(6 7))))
is being show 2 while the same
(length (car '((0)(1 2 3)(6 7))))
is correctly shown 1. so what does the the first expression actually represent?
Upvotes: 2
Views: 567
Reputation: 139241
CL-USER 8 > '((0)(1 2 3)(6 7))
((0)
(1 2 3)
(6 7))
CL-USER 9 > '('(0)'(1 2 3)'(6 7))
((QUOTE (0))
(QUOTE (1 2 3))
(QUOTE (6 7)))
Upvotes: 1
Reputation: 780673
The quote character '
is a reader macro. 'anything
expands into (quote anything)
. So the first expression is shorthand for:
(length (car (quote ((quote (0))
(quote (1 2 3))
(quote (6 7)))
The first quote
causes the parameter to be treated literally. That means that the quote
expressions inside it are just lists that happen to begin with the symbol quote
.
So the CAR of that list is the sub-list (quote (0))
. It contains 2 elements: the symbol quote
and the list (0)
.
Upvotes: 7