1
0
Fork 0
cl-sites/novaspec.org/cl/f_equalp.html

853 lines
17 KiB
HTML
Raw Normal View History

2025-02-05 18:52:26 +01:00
<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>equalp | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_equalp.html"
><LINK REL="next" HREF="f_identity.html" TYPE="text/html" TITLE="identity"
><LINK REL="prev" HREF="f_equal.html" TYPE="text/html" TITLE="equal"
><LINK REL="up" HREF="5_3_Data_and_Control_Flow_Dictionary.html" TYPE="text/html" TITLE="5.3 Data and Control Flow Dictionary"
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
><SCRIPT SRC="dpans.js%3F3909942064"
></SCRIPT
><SCRIPT SRC="apropos.js%3F3909942064"
></SCRIPT
></HEAD
><BODY
><DIV
><DIV CLASS="topnav"
><DIV CLASS="breadcrumb"
><SPAN CLASS="breadcrumb-item"
><A HREF="index.html"
>Common Lisp Nova Spec</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="5_Data_and_Control_Flow.html"
>5. Data and Control Flow</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="5_3_Data_and_Control_Flow_Dictionary.html"
>5.3 Data and Control Flow Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="f_equalp.html"
>equalp</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_equal.html" CLASS="prev"
>&#8592;</A
><SPAN ID="apropos-label"
>Apropos </SPAN
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
><A HREF="f_identity.html" CLASS="next"
>&#8594;</A
></DIV
><DIV ID="apropos-res"
></DIV
></DIV
></DIV
><DIV CLASS="matter"
><DIV CLASS="com"
><DIV CLASS="begincom"
><HR
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="equalp"
></SPAN
><B
>equalp</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Function</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><P CLASS="j"
><B
>equalp</B
> <SPAN CLASS="cmssi"
>x</SPAN
> <SPAN CLASS="cmssi"
>y</SPAN
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmssi"
>generalized-boolean</SPAN
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>x</VAR
> &#8212; an <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>y</VAR
> &#8212; an <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>generalized-boolean</VAR
> &#8212; a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
>Returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> if <VAR CLASS="param"
>x</VAR
> and <VAR CLASS="param"
>y</VAR
> are <A HREF="f_equal.html" CLASS="funref"
><B
>equal</B
></A
>, or if they have components that are of the same <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> as each other and if those components are <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
>; specifically, <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> in the following cases:</P
><DL
><DT
><A HREF="26_1_Glossary.html#character"
><EM CLASS="term"
>Characters</EM
></A
></DT
><DD
><P CLASS="j"
>If two <A HREF="26_1_Glossary.html#character"
><EM CLASS="term"
>characters</EM
></A
> are <A HREF="f_char_eq.html" CLASS="funref"
><B
>char-equal</B
></A
>.</P
></DD
><DT
><A HREF="26_1_Glossary.html#number"
><EM CLASS="term"
>Numbers</EM
></A
></DT
><DD
><P CLASS="j"
>If two <A HREF="26_1_Glossary.html#number"
><EM CLASS="term"
>numbers</EM
></A
> are the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> under <A HREF="f__eq.html" CLASS="funref"
><B
>=</B
></A
>.</P
></DD
><DT
><A HREF="26_1_Glossary.html#cons"
><EM CLASS="term"
>Conses</EM
></A
></DT
><DD
><P CLASS="j"
>If the two <A HREF="26_1_Glossary.html#car"
><EM CLASS="term"
>cars</EM
></A
> in the <A HREF="26_1_Glossary.html#cons"
><EM CLASS="term"
>conses</EM
></A
> are <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> and the two <A HREF="26_1_Glossary.html#cdr"
><EM CLASS="term"
>cdrs</EM
></A
> in the <A HREF="26_1_Glossary.html#cons"
><EM CLASS="term"
>conses</EM
></A
> are <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
>.</P
></DD
><DT
><A HREF="26_1_Glossary.html#array"
><EM CLASS="term"
>Arrays</EM
></A
></DT
><DD
><P CLASS="j"
>If two <A HREF="26_1_Glossary.html#array"
><EM CLASS="term"
>arrays</EM
></A
> have the same number of dimensions, the dimensions match, and the corresponding <EM CLASS="term"
>active elements</EM
> are <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
>. The <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>types</EM
></A
> for which the <A HREF="26_1_Glossary.html#array"
><EM CLASS="term"
>arrays</EM
></A
> are <A HREF="26_1_Glossary.html#specialized"
><EM CLASS="term"
>specialized</EM
></A
> need not match; for example, a <A HREF="26_1_Glossary.html#string"
><EM CLASS="term"
>string</EM
></A
> and a general <A HREF="26_1_Glossary.html#array"
><EM CLASS="term"
>array</EM
></A
> that happens to contain the same <A HREF="26_1_Glossary.html#character"
><EM CLASS="term"
>characters</EM
></A
> are <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
>. Because <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> performs <A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>element</EM
></A
>-by-<A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>element</EM
></A
> comparisons of <A HREF="26_1_Glossary.html#string"
><EM CLASS="term"
>strings</EM
></A
> and ignores the <A HREF="26_1_Glossary.html#case"
><EM CLASS="term"
>case</EM
></A
> of <A HREF="26_1_Glossary.html#character"
><EM CLASS="term"
>characters</EM
></A
>, <A HREF="26_1_Glossary.html#case"
><EM CLASS="term"
>case</EM
></A
> distinctions are ignored when <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> compares <A HREF="26_1_Glossary.html#string"
><EM CLASS="term"
>strings</EM
></A
>.</P
></DD
><DT
><A HREF="26_1_Glossary.html#structure"
><EM CLASS="term"
>Structures</EM
></A
></DT
><DD
><P CLASS="j"
>If two <A HREF="26_1_Glossary.html#structure"
><EM CLASS="term"
>structures</EM
></A
> <I
>S</I
><SUB CLASS="sub"
><SPAN CLASS="cmr"
>1</SPAN
></SUB
> and <I
>S</I
><SUB CLASS="sub"
><SPAN CLASS="cmr"
>2</SPAN
></SUB
> have the same <A HREF="26_1_Glossary.html#class"
><EM CLASS="term"
>class</EM
></A
> and the value of each <A HREF="26_1_Glossary.html#slot"
><EM CLASS="term"
>slot</EM
></A
> in <I
>S</I
><SUB CLASS="sub"
><SPAN CLASS="cmr"
>1</SPAN
></SUB
> is the <A HREF="26_1_Glossary.html#same"
><EM CLASS="term"
>same</EM
></A
> under <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> as the value of the corresponding <A HREF="26_1_Glossary.html#slot"
><EM CLASS="term"
>slot</EM
></A
> in <I
>S</I
><SUB CLASS="sub"
><SPAN CLASS="cmr"
>2</SPAN
></SUB
>.</P
></DD
><DT
><A HREF="26_1_Glossary.html#hash_table"
><EM CLASS="term"
>Hash Tables</EM
></A
></DT
><DD
><P CLASS="j"
><A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> descends <EM CLASS="term"
>hash-tables</EM
> by first comparing the count of entries and the <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:test</SPAN
></SPAN
> function; if those are the same, it compares the keys of the tables using the <SPAN CLASS="kwd"
><SPAN CLASS="cmtt"
>:test</SPAN
></SPAN
> function and then the values of the matching keys using <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> recursively.</P
></DD
></DL
><P CLASS="j"
><A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> does not descend any <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>objects</EM
></A
> other than the ones explicitly specified above. Figure 5&#8211;13 summarizes the information given in the previous list. In addition, the figure specifies the priority of the behavior of <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
>, with upper entries taking priority over lower ones.</P
><FIGURE CLASS="boxfig"
><DIV CLASS="figbody"
><TABLE CELLSPACING="0" CELLPADDING="0" RULES="GROUPS" STYLE="margin: 1ex 0" WIDTH="100%"
><THEAD
><TR
><TH ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
><B
>Type</B
></TH
><TH ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <B
>Behavior</B
></TH
></TR
></THEAD
><TBODY
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#number"
><EM CLASS="term"
>number</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>uses</SPAN
> <A HREF="f__eq.html" CLASS="funref"
><B
>=</B
></A
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#character"
><EM CLASS="term"
>character</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>uses</SPAN
> <A HREF="f_char_eq.html" CLASS="funref"
><B
>char-equal</B
></A
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#cons"
><EM CLASS="term"
>cons</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>descends</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#bit_vector"
><EM CLASS="term"
>bit vector</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>descends</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#string"
><EM CLASS="term"
>string</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>descends</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#pathname"
><EM CLASS="term"
>pathname</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>same</SPAN
> <SPAN CLASS="cmr"
>as</SPAN
> <A HREF="f_equal.html" CLASS="funref"
><B
>equal</B
></A
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#structure"
><EM CLASS="term"
>structure</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>descends,</SPAN
> <SPAN CLASS="cmr"
>as</SPAN
> <SPAN CLASS="cmr"
>described</SPAN
> <SPAN CLASS="cmr"
>above</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <SPAN CLASS="cmr"
>Other</SPAN
> <A HREF="26_1_Glossary.html#array"
><EM CLASS="term"
>array</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>descends</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <A HREF="26_1_Glossary.html#hash_table"
><EM CLASS="term"
>hash table</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>descends,</SPAN
> <SPAN CLASS="cmr"
>as</SPAN
> <SPAN CLASS="cmr"
>described</SPAN
> <SPAN CLASS="cmr"
>above</SPAN
></TD
></TR
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE=";padding-right:3px"
> <SPAN CLASS="cmr"
>Other</SPAN
> <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
></TD
><TD ALIGN="LEFT" VALIGN="BASELINE" STYLE="padding-left:3px;"
> <SPAN CLASS="cmr"
>uses</SPAN
> <A HREF="f_eq.html" CLASS="funref"
><B
>eq</B
></A
></TD
></TR
></TBODY
></TABLE
></DIV
><FIGCAPTION CLASS="caption"
><B
>Figure 5&#8211;13. Summary and priorities of behavior of</B
> <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
></FIGCAPTION
></FIGURE
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
>(equalp 'a 'b) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>
(equalp 'a 'a) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp 3 3) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp 3 3.0) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp 3.0 3.0) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp #c(3 -4) #c(3 -4)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp #c(3 -4.0) #c(3 -4)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp (cons 'a 'b) (cons 'a 'c)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>
(equalp (cons 'a 'b) (cons 'a 'b)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp #\A #\A) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp #\A #\a) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp "Foo" "Foo") <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp "Foo" (copy-seq "Foo")) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(equalp "FOO" "foo") <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
></PRE
><PRE CLASS="screen"
> (setq array1 (make-array 6 :element-type 'integer
:initial-contents '(1 1 1 3 5 7)))
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> #(1 1 1 3 5 7)
(setq array2 (make-array 8 :element-type 'integer
:initial-contents '(1 1 1 3 5 7 2 6)
:fill-pointer 6))
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> #(1 1 1 3 5 7)
(equalp array1 array2) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(setq vector1 (vector 1 1 1 3 5 7)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> #(1 1 1 3 5 7)
(equalp array1 vector1) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
></PRE
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_eq.html" CLASS="funref"
><B
>eq</B
></A
>, <A HREF="f_eql.html" CLASS="funref"
><B
>eql</B
></A
>, <A HREF="f_equal.html" CLASS="funref"
><B
>equal</B
></A
>, <A HREF="f__eq.html" CLASS="funref"
><B
>=</B
></A
>, <A HREF="f_string_eq.html" CLASS="funref"
><B
>string=</B
></A
>, <A HREF="f_string_eq.html" CLASS="funref"
><B
>string-equal</B
></A
>, <A HREF="f_char_eq.html" CLASS="funref"
><B
>char=</B
></A
>, <A HREF="f_char_eq.html" CLASS="funref"
><B
>char-equal</B
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><P CLASS="j"
><A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>Object</EM
></A
> equality is not a concept for which there is a uniquely determined correct algorithm. The appropriateness of an equality predicate can be judged only in the context of the needs of some particular program. Although these functions take any type of argument and their names sound very generic, <A HREF="f_equal.html" CLASS="funref"
><B
>equal</B
></A
> and <A HREF="f_equalp.html" CLASS="funref"
><B
>equalp</B
></A
> are not appropriate for every application.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_equal.html" CLASS="prev"
>&#8592;</A
><A HREF="f_identity.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>