[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: To be a list or not
From: |
Stephen J. Turnbull |
Subject: |
Re: To be a list or not |
Date: |
Sun, 30 Dec 2007 06:11:16 +0900 |
Bob Rogers writes:
> 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 please call it `true-list-p', which is the name of the similar
XEmacs built-in. The XEmacs built-in uses a tortoise-hare algorithm
to ensure that cyclic lists are caught. I don't know who may have
touched it so I won't post code here.
As several people have pointed out, it's still O(n). In most cases it
make a lot more sense to use a condition-case around your list-
processing code and handle the error thrown appropriately only for the
last cons.
`true-list-p' is a built-in function
-- loaded from "/playpen/src/XEmacs/git-integration/src/data.c"
(true-list-p OBJECT)
Documentation:
Return t if OBJECT is an acyclic, nil-terminated (ie, not dotted), list.
- 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, 2007/12/28
- Re: To be a list or not,
Stephen J. Turnbull <=
- 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
Re: To be a list or not, Eric Hanchrow, 2007/12/28