help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: 'length' function for lists and cons cells?


From: Thorsten Jolitz
Subject: Re: 'length' function for lists and cons cells?
Date: Thu, 21 Mar 2013 22:58:35 +0100
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.2 (gnu/linux)

Stephen Berman <stephen.berman@gmx.net> writes:

>> which function could I use when I map an alist e.g. with dolist, that
>> contains both types of associations as shown below: cons cells, or lists
>> with 3 or more elements?
>>
>> 'length' doesn't work on cons cells:
>
> Since a cons cells always contains exactly two members (its car and its
> cdr), why do you want to call a function to find its length?

actually I'm looking for a way to distinguish between cons cells and
regular lists to avoid the errors when mapping an alist that contains
both with functions that work only on one of them, using 'length' was
just a hack. 

I would have thought that 'consp' might be the right function, but:

,-----------------------
| (consp '("a" "b" "c"))
| t
| 
| (consp '("a" . "c"))
| t
`-----------------------

-- 
cheers,
Thorsten




reply via email to

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