[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: To be a list or not
From: |
Bob Rogers |
Subject: |
Re: To be a list or not |
Date: |
Fri, 28 Dec 2007 22:35:41 -0500 |
From: "Lennart Borgman (gmail)" <address@hidden>
Date: Sat, 29 Dec 2007 01:18:34 +0100
. . .
However (sequencp '(prop . val)) returns t.
What I wanted to know was the recommended way to check if something
is a cons cell, but not a sequence, ie something like '(prop . val).
This is called an "improper list"; you could check for it thus:
(defun proper-list-p (x)
(and (listp x)
(null (cdr (last x)))))
But of course, this is O(N), and would not even terminate for circular
lists, which is why the predicates are designed not to go to all that
trouble.
FWIW, format.el defines a format-proper-list-p that is equivalent.
-- Bob Rogers
http://rgrjr.dyndns.org/
- To be a list or not, Lennart Borgman (gmail), 2007/12/28
- Re: To be a list or not, Nick Roberts, 2007/12/28
- Re: To be a list or not, Lennart Borgman (gmail), 2007/12/28
- Re: To be a list or not, Nick Roberts, 2007/12/28
- Re: To be a list or not, Lennart Borgman (gmail), 2007/12/28
- Re: To be a list or not,
Bob Rogers <=
- Re: To be a list or not, Stephen J. Turnbull, 2007/12/29
- Re: To be a list or not, Miles Bader, 2007/12/29
- Re: To be a list or not, Tom Tromey, 2007/12/29
- Re: To be a list or not, Andreas Schwab, 2007/12/29
- Re: To be a list or not, Tom Tromey, 2007/12/31
- Re: To be a list or not, Andreas Schwab, 2007/12/31
- Re: To be a list or not, Stephen J. Turnbull, 2007/12/29
- Re: To be a list or not, Bob Rogers, 2007/12/29
- Re: To be a list or not, Richard Stallman, 2007/12/29
- Re: To be a list or not, Richard Stallman, 2007/12/29