emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lists, plain conses and length


From: Lars Ingebrigtsen
Subject: Re: lists, plain conses and length
Date: Fri, 04 Sep 2020 04:29:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

"T.V Raman" <raman@google.com> writes:

> (length a)=> Debugger entered--Lisp error: (wrong-type-argument listp 2)
>
> Q: how does one distinguish a cons from a list.
> The error  message for length may need fixing since it says the
> argument passed to it is not a list (it's correct) but then listp is wrong?

`length' (and many other functions) require what's called a "proper
list", which simply means that the cdr of the last cons cell is nil.

(length '(1 2 . 3))
-> (wrong-type-argument listp 3)

The predicate to use here is `proper-list-p'.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no



reply via email to

[Prev in Thread] Current Thread [Next in Thread]