3

Ideally in LISP:

caddr[(A B C)] = car[cdr[cdr[(A B C)]]] = car[cdr[(B C)]] = car[C] = Undefined.

But the book says answer is C. Can anyone please explain?

Thanks a lot.

Drew
  • 29,895
  • 7
  • 74
  • 104
nrb
  • 31
  • 3

2 Answers2

17

Your mistake is that cdr[(B C)] is the list (C), not the atom C.

Then car[(C)] is C.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
6

(cdr '(b c)) is the list (c), not the atom c, so the expression becomes (car '(c)) not (car c)

? (cdr '(b c))
(C)

? (car '(c))
C
uselpa
  • 18,732
  • 2
  • 34
  • 52