emacs-devel
[Top][All Lists]
Advanced

[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/




reply via email to

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