summaryrefslogtreecommitdiff
path: root/devdocs/elisp/list_002drelated-predicates.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/list_002drelated-predicates.html
new repository
Diffstat (limited to 'devdocs/elisp/list_002drelated-predicates.html')
-rw-r--r--devdocs/elisp/list_002drelated-predicates.html45
1 files changed, 45 insertions, 0 deletions
diff --git a/devdocs/elisp/list_002drelated-predicates.html b/devdocs/elisp/list_002drelated-predicates.html
new file mode 100644
index 00000000..03c7692e
--- /dev/null
+++ b/devdocs/elisp/list_002drelated-predicates.html
@@ -0,0 +1,45 @@
+ <h3 class="section">Predicates on Lists</h3> <p>The following predicates test whether a Lisp object is an atom, whether it is a cons cell or is a list, or whether it is the distinguished object <code>nil</code>. (Many of these predicates can be defined in terms of the others, but they are used so often that it is worth having them.) </p> <dl> <dt id="consp">Function: <strong>consp</strong> <em>object</em>
+</dt> <dd><p>This function returns <code>t</code> if <var>object</var> is a cons cell, <code>nil</code> otherwise. <code>nil</code> is not a cons cell, although it <em>is</em> a list. </p></dd>
+</dl> <dl> <dt id="atom">Function: <strong>atom</strong> <em>object</em>
+</dt> <dd>
+<p>This function returns <code>t</code> if <var>object</var> is an atom, <code>nil</code> otherwise. All objects except cons cells are atoms. The symbol <code>nil</code> is an atom and is also a list; it is the only Lisp object that is both. </p> <div class="example"> <pre class="example">(atom <var>object</var>) ≡ (not (consp <var>object</var>))
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="listp">Function: <strong>listp</strong> <em>object</em>
+</dt> <dd>
+<p>This function returns <code>t</code> if <var>object</var> is a cons cell or <code>nil</code>. Otherwise, it returns <code>nil</code>. </p> <div class="example"> <pre class="example">(listp '(1))
+ ⇒ t
+</pre>
+<pre class="example">(listp '())
+ ⇒ t
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="nlistp">Function: <strong>nlistp</strong> <em>object</em>
+</dt> <dd>
+<p>This function is the opposite of <code>listp</code>: it returns <code>t</code> if <var>object</var> is not a list. Otherwise, it returns <code>nil</code>. </p> <div class="example"> <pre class="example">(listp <var>object</var>) ≡ (not (nlistp <var>object</var>))
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="null">Function: <strong>null</strong> <em>object</em>
+</dt> <dd>
+<p>This function returns <code>t</code> if <var>object</var> is <code>nil</code>, and returns <code>nil</code> otherwise. This function is identical to <code>not</code>, but as a matter of clarity we use <code>null</code> when <var>object</var> is considered a list and <code>not</code> when it is considered a truth value (see <code>not</code> in <a href="combining-conditions">Combining Conditions</a>). </p> <div class="example"> <pre class="example">(null '(1))
+ ⇒ nil
+</pre>
+<pre class="example">(null '())
+ ⇒ t
+</pre>
+</div> </dd>
+</dl> <dl> <dt id="proper-list-p">Function: <strong>proper-list-p</strong> <em>object</em>
+</dt> <dd>
+<p>This function returns the length of <var>object</var> if it is a proper list, <code>nil</code> otherwise (see <a href="cons-cells">Cons Cells</a>). In addition to satisfying <code>listp</code>, a proper list is neither circular nor dotted. </p> <div class="example"> <pre class="example">(proper-list-p '(a b c))
+ ⇒ 3
+</pre>
+<pre class="example">(proper-list-p '(a b . c))
+ ⇒ nil
+</pre>
+</div> </dd>
+</dl><div class="_attribution">
+ <p class="_attribution-p">
+ Copyright &copy; 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
+ <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/List_002drelated-Predicates.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/List_002drelated-Predicates.html</a>
+ </p>
+</div>