1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<HTML>
<HEAD>
<TITLE>Common LISP Hints: Equality</TITLE>
</HEAD>
<BODY>
<A HREF="LISP-tutorial-22.html"><IMG SRC="prev.gif" ALT="Previous"></A>
<A HREF="LISP-tutorial-24.html"><IMG SRC="next.gif" ALT="Next"></A>
<A HREF="LISP-tutorial.html#toc23"><IMG SRC="toc.gif" ALT="Contents"></A>
<HR>
<H2><A NAME="s23">23. Equality</A></H2>
<P>LISP has many different ideas of equality. Numerical equality is
denoted by <CODE>=</CODE>. Two symbols are <CODE>eq</CODE> if and only if they are
identical. Two
copies of the same list are not <CODE>eq</CODE>, but they are equal.</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
> (eq 'a 'a)
T
> (eq 'a 'b)
NIL
> (= 3 4)
T
> (eq '(a b c) '(a b c))
NIL
> (equal '(a b c) '(a b c))
T
> (eql 'a 'a)
T
> (eql 3 3)
T
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>The <CODE>eql</CODE> predicate is equivalent to <CODE>eq</CODE> for symbols and to
<CODE>=</CODE> for numbers. </P>
<P>The <CODE>equal</CODE> predicate is equivalent to <CODE>eql</CODE> for symbols and
numbers. It is
true for two conses if and only if their cars are equal and their cdrs
are equal. It is true for two structures if and only if the structures
are the same type and their corresponding fields are equal.</P>
<HR>
<A HREF="LISP-tutorial-22.html"><IMG SRC="prev.gif" ALT="Previous"></A>
<A HREF="LISP-tutorial-24.html"><IMG SRC="next.gif" ALT="Next"></A>
<A HREF="LISP-tutorial.html#toc23"><IMG SRC="toc.gif" ALT="Contents"></A>
</BODY>
</HTML>
|