CyberShot
CyberShot

Reputation: 2335

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?

Upvotes: 1

Views: 348

Answers (1)

markw
markw

Reputation: 630

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 '()

Upvotes: 7

Related Questions