# Re: cdr vs. nthcdr

*From*: Stefan Nobis <snobis@xxxxxx>*Date*: Thu, 01 Mar 2007 08:05:11 +0100

"lojic" <lojicdotcom@xxxxxxxxx> writes:

I'm sure I have a fundamental misunderstanding wrt cdr & nthcdr, but

the fact that the following expression is nil bothers me:

(and

lst

(eql

(eql

(car lst)

(nth 0 lst))

(eql

(cdr lst)

(nthcdr 0 lst))))

Why do you assume that the car and cdr of a cons should be eql?

I discovered this while working through "ANSI Common Lisp" and seeing

the following on p. 40:

(maplist #'(lambda (x) x) '(a b c))

which gives

((A B C) (B C) (C))

where I expected

((B C) (C))

since (cdr '(a b c)) gives (B C)

CLHS says:

,----

| function is first applied to the lists themselves, and then to the

| cdr of each list, and then to the cdr of the cdr of each list, and

| so on.

`----

--

Stefan.

.

**Follow-Ups**:**Re: cdr vs. nthcdr***From:*Brian Adkins

**References**:**cdr vs. nthcdr***From:*lojic

- Prev by Date:
**Re: cdr vs. nthcdr** - Next by Date:
**Re: A style question** - Previous by thread:
**Re: cdr vs. nthcdr** - Next by thread:
**Re: cdr vs. nthcdr** - Index(es):