82 lines
8.4 KiB
HTML
82 lines
8.4 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Function EQL</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="f_eq.htm">
|
|
<LINK REL=UP HREF="c_data_a.htm">
|
|
<LINK REL=NEXT HREF="f_equal.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="f_eq.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_data_a.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_equal.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="eql"><I>Function</I> <B>EQL</B></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>eql</B> <I>x y</I> => <I>generalized-boolean</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>x</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. <P>
|
|
<I>y</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. <P>
|
|
<I>generalized-boolean</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
The value of <A REL=DEFINITION HREF="#eql"><B>eql</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> of two objects, <I>x</I> and <I>y</I>, in the folowing cases: <P><DL><DT>1. If <I>x</I> and <I>y</I> are <A REL=DEFINITION HREF="f_eq.htm#eq"><B>eq</B></A>. <DD><DT>2. If <I>x</I> and <I>y</I> are both <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>numbers</I></A> of the same <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> and the same value. <DD><DT>3. If they are both <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A> that represent the same character. <P><DD></DL><P>
|
|
Otherwise the value of <A REL=DEFINITION HREF="#eql"><B>eql</B></A> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
If an implementation supports positive and negative zeros as <A REL=DEFINITION HREF="26_glo_d.htm#distinct"><I>distinct</I></A> values, then <TT>(eql 0.0 -0.0)</TT> returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. Otherwise, when the syntax <TT>-0.0</TT> is read it is interpreted as the value <TT>0.0</TT>, and so <TT>(eql 0.0 -0.0)</TT> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(eql 'a 'b) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(eql 'a 'a) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(eql 3 3) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(eql 3 3.0) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(eql 3.0 3.0) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(eql #c(3 -4) #c(3 -4)) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(eql #c(3 -4.0) #c(3 -4)) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(eql (cons 'a 'b) (cons 'a 'c)) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(eql (cons 'a 'b) (cons 'a 'b)) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(eql '(a . b) '(a . b))
|
|
=> <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
OR=> <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(progn (setq x (cons 'a 'b)) (eql x x)) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(progn (setq x '(a . b)) (eql x x)) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(eql #\A #\A) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(eql "Foo" "Foo")
|
|
=> <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
OR=> <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(eql "Foo" (copy-seq "Foo")) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(eql "FOO" "foo") => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
</PRE>
|
|
</TT> <P>
|
|
Normally <TT>(eql 1.0s0 1.0d0)</TT> is false, under the assumption that <TT>1.0s0</TT> and <TT>1.0d0</TT> are of distinct data types. However, implementations that do not provide four distinct floating-point formats are permitted to ``collapse'' the four formats into some smaller number of them; in such an implementation <TT>(eql 1.0s0 1.0d0)</TT> might be true. <P>
|
|
<P><B>Side Effects:</B> None.
|
|
<P>
|
|
<P><B>Affected By:</B> None.
|
|
<P>
|
|
<P><B>Exceptional Situations:</B> None.
|
|
<P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_eq.htm#eq"><B>eq</B></A>, <A REL=DEFINITION HREF="f_equal.htm#equal"><B>equal</B></A>, <A REL=DEFINITION HREF="f_equalp.htm#equalp"><B>equalp</B></A>, <A REL=DEFINITION HREF="f_eq_sle.htm#EQ"><B>=</B></A>, <A REL=DEFINITION HREF="f_chareq.htm#charEQ"><B>char=</B></A> <P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#eql"><B>eql</B></A> is the same as <A REL=DEFINITION HREF="f_eq.htm#eq"><B>eq</B></A>, except that if the arguments are <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A> or <A REL=DEFINITION HREF="26_glo_n.htm#number"><I>numbers</I></A> of the same type then their values are compared. Thus <A REL=DEFINITION HREF="#eql"><B>eql</B></A> tells whether two <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> are conceptually the same, whereas <A REL=DEFINITION HREF="f_eq.htm#eq"><B>eq</B></A> tells whether two <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> are implementationally identical. It is for this reason that <A REL=DEFINITION HREF="#eql"><B>eql</B></A>, not <A REL=DEFINITION HREF="f_eq.htm#eq"><B>eq</B></A>, is the default comparison predicate for <A REL=DEFINITION HREF="26_glo_o.htm#operator"><I>operators</I></A> that take <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequences</I></A> as arguments. <P>
|
|
<A REL=DEFINITION HREF="#eql"><B>eql</B></A> may not be true of two <A REL=DEFINITION HREF="26_glo_f.htm#float"><I>floats</I></A> even when they represent the same value. <A REL=DEFINITION HREF="f_eq_sle.htm#EQ"><B>=</B></A> is used to compare mathematical values. <P>
|
|
Two <A REL=DEFINITION HREF="26_glo_c.htm#complex"><I>complex</I></A> numbers are considered to be <A REL=DEFINITION HREF="#eql"><B>eql</B></A> if their real parts are <A REL=DEFINITION HREF="#eql"><B>eql</B></A> and their imaginary parts are <A REL=DEFINITION HREF="#eql"><B>eql</B></A>. For example, <TT>(eql #C(4 5) #C(4 5))</TT> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> and <TT>(eql #C(4 5) #C(4.0 5.0))</TT> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. Note that while <TT>(eql #C(5.0 0.0) 5.0)</TT> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, <TT>(eql #C(5 0) 5)</TT> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. In the case of <TT>(eql #C(5.0 0.0) 5.0)</TT> the two arguments are of different types, and so cannot satisfy <A REL=DEFINITION HREF="#eql"><B>eql</B></A>. In the case of <TT>(eql #C(5 0) 5)</TT>, <TT>#C(5 0)</TT> is not a <A REL=DEFINITION HREF="26_glo_c.htm#complex"><I>complex</I></A> number, but is automatically reduced to the <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A> <TT>5</TT>. <P>
|
|
<HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|