Search code examples
lispcdr

LISP cdr function


If I do

(setq x   '(NOT (NOT (NOT (NOT A)))) )

(cdr x) is (NOT (NOT (NOT A))))

but (cdr (cdr x)) is NIL

What's going on here?


Solution

  • Um, it shouldn't. (cdr x) should give you '((NOT (NOT (NOT A)))). Which means (NOT (NOT (NOT A))) is the first element of (cdr x). When you cdr again it's on a one-element list, so you get nil '()