emacs.d/clones/lisp/colinallen.dnsalias.org/lp/node92.html

115 lines
2.6 KiB
HTML
Raw Normal View History

2022-08-02 12:34:59 +02:00
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Originally converted to HTML using LaTeX2HTML 95 (Thu Jan 19 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE> eql, equal (PREDICATES)</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" eql, equal (PREDICATES)">
<meta name="keywords" value="lp">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR>
<A HREF="node93.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A>
<A HREF="node72.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A>
<A HREF="node91.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <BR>
<A HREF="lp.html"><B>Contents</B></A>
<B> Next:</B>
<A HREF="node93.html"> eval (FUNCTION)</A>
<B>Up:</B>
<A HREF="node72.html"> Appendix: Selected Lisp </A>
<B> Previous:</B>
<A HREF="node91.html"> documentation (FUNCTION)</A>
<BR> <HR> <P>
<H1> eql, equal (PREDICATES)</H1>
<P>
<b> Format:</b>
<tt> (eql &lt;exp1&gt; &lt;exp2&gt; )</tt>
<P>
<b> Required arguments:</b>
2
<P>
<tt> &lt;exp1&gt; </tt>: any Lisp expression
<tt> &lt;exp2&gt; </tt>: any Lisp expression
<P>
Both argument expressions are evaluated. If they both return
atoms, eql returns T if they are the same. If they return lists,
eql returns T only if the lists are represented by the same object
in memory. In contrast, two values can be ``equal'' if they are
copies of one another (perhaps existing in different memory locations).
<P>
<b> Examples:</b>
<P>
<BLOCKQUOTE>
<PRE>&gt; (eql 'hello 'hello)
T
&gt; (eql -19 -19)
T
&gt; (eql 2 3)
NIL
&gt; (eql '(1 2 3) '(1 2 3))
NIL
&gt; (setq a '(1 2 3))
(1 2 3)
&gt; (setq b '(1 2 3))
(1 2 3)
&gt; (eql a b)
NIL
&gt; (setq c a)
(1 2 3)
&gt; (eql a c)
T
&gt; (eql b c)
NIL
</PRE>
</BLOCKQUOTE>
<P>
<b> Format:</b>
<tt> (equal &lt;exp1&gt; &lt;exp2&gt; )</tt>
<P>
<b> Required arguments:</b>
2
<P>
<tt> &lt;exp1&gt; </tt>: any Lisp expression
<tt> &lt;exp2&gt; </tt>: any Lisp expression
<P>
Both argument expressions are evaluated. If the values returned
are copies of one another (or even are physically the same by
occupying the same memory), equal returns T. In contrast, for two
lists to be eql they must represent the same object in memory.
<P>
<b> Examples:</b>
<P>
<BLOCKQUOTE>
<PRE>&gt; (equal 'hey 'hello)
NIL
&gt; (equal -81 -81)
T
&gt; (equal '(1 (2 3)) '(1 (2 3)))
T
&gt; (setq a '(1 2 3))
(1 2 3)
&gt; (setq b '(1 2 3))
(1 2 3)
&gt; (equal a b)
T
&gt; (setq c a)
(1 2 3)
&gt; (equal a c)
T
</PRE>
</BLOCKQUOTE>
<P>
<BR> <HR>
<P>
<ADDRESS>
<I>&#169; Colin Allen &amp; Maneesh Dhagat <BR>
March 2007 </I>
</ADDRESS>
</BODY>