Christophe Rhodes <csr21@...> writes:
> Nicolas Neuss <Nicolas.Neuss@...> writes:
> > Lars Brinkhoff <lars@...> writes:
> >> Should it? CLHS says "(butlast list n) == (ldiff list (last list n))".
> >> (last '(1 2 . 3) 0) is 3, and (ldiff '(1 2 . 3) 3) is (1 2).
> > Hmm. So CLHS is ambiguous here and both CMUCL and SBCL are right in what
> > they do. Only my code is wrong in relying on it :-)
> Interesting question. Technically, the "Notes" section of dictionary
> entries is non-normative -- that is, it is explanation, but it is not
> a part of the standard. The _description_ of BUTLAST does seem to
> imply that SBCL is right and CMUCL is wrong, but... maybe this is one
> of the cases where the Lisp oral tradition trumps minor things like
> standards :-)
As much as I see even the description is contradictory. The first
paragraph supports SBCL, the second one CMUCL (probably because the writer
did not think of improper lists at this point).
butlast returns a copy of list from which the last n conses have been
omitted. If n is not supplied, its value is 1. If there are fewer than n
conses in list, nil is returned and, in the case of nbutlast, list is not
nbutlast is like butlast, but nbutlast may modify list. It changes the cdr
of the cons n+1 from the end of the list to nil.