122 lines
13 KiB
HTML
122 lines
13 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 STRING=, STRING/=, STRING<...</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_stg_tr.htm">
|
|
<LINK REL=UP HREF="c_string.htm">
|
|
<LINK REL=NEXT HREF="f_stgp.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_stg_tr.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_string.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="f_stgp.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="stringEQ"><A NAME="stringSLEQ"><A NAME="stringLT"><A NAME="stringGT"><A NAME="stringLTEQ"><A NAME="stringGTEQ"><A NAME="string-equal"><A NAME="string-not-equal"><A NAME="string-lessp"><A NAME="string-greaterp"><A NAME="string-not-greaterp"><A NAME="string-not-lessp"><I>Function</I> <B>STRING=, STRING/=, STRING<, STRING>, STRING<=, STRING>=, STRING-EQUAL, STRING-NOT-EQUAL, STRING-LESSP, STRING-GREATERP, STRING-NOT-GREATERP, STRING-NOT-LESSP</B></A></A></A></A></A></A></A></A></A></A></A></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>string=</B> <I>string1 string2 <TT>&key</TT> start1 end1 start2 end2</I> => <I>generalized-boolean</I><P>
|
|
<P>
|
|
|
|
<B>string/=</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string<</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string></B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string<=</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string>=</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
<P>
|
|
|
|
<B>string-equal</B> <I>string1 string2 <TT>&key</TT> start1 end1 start2 end2</I> => <I>generalized-boolean</I><P>
|
|
<P>
|
|
|
|
<B>string-not-equal</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string-lessp</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string-greaterp</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string-not-greaterp</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
|
|
<B>string-not-lessp</B> <I>string1 string2 </I><TT>&key</TT><I> start1 end1 start2 end2</I> => <I>mismatch-index</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>string1</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#string_designator"><I>string designator</I></A>. <P>
|
|
<I>string2</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#string_designator"><I>string designator</I></A>. <P>
|
|
<I>start1</I>, <I>end1</I>---<A REL=DEFINITION HREF="26_glo_b.htm#bounding_index_designator"><I>bounding index designators</I></A> of <I>string1</I>. The defaults for <I>start</I> and <I>end</I> are <TT>0</TT> and <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>, respectively. <P>
|
|
<I>start2</I>, <I>end2</I>---<A REL=DEFINITION HREF="26_glo_b.htm#bounding_index_designator"><I>bounding index designators</I></A> of <I>string2</I>. The defaults for <I>start</I> and <I>end</I> are <TT>0</TT> and <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>, respectively. <P>
|
|
<I>generalized-boolean</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>mismatch-index</I>---a <A REL=DEFINITION HREF="26_glo_b.htm#bounding_index"><I>bounding index</I></A> of <I>string1</I>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
These functions perform lexicographic comparisons on <I>string1</I> and <I>string2</I>. <A REL=DEFINITION HREF="#stringEQ"><B>string=</B></A> and <A REL=DEFINITION HREF="#string-equal"><B>string-equal</B></A> are called equality functions; the others are called inequality functions. The comparison operations these <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>functions</I></A> perform are restricted to the subsequence of <I>string1</I> <A REL=DEFINITION HREF="26_glo_b.htm#bounded"><I>bounded</I></A> by <I>start1</I> and <I>end1</I> and to the subsequence of <I>string2</I> <A REL=DEFINITION HREF="26_glo_b.htm#bounded"><I>bounded</I></A> by <I>start2</I> and <I>end2</I>. <P>
|
|
A string <I>a</I> is equal to a string <I>b</I> if it contains the same number of characters, and the corresponding characters are the <A REL=DEFINITION HREF="26_glo_s.htm#same"><I>same</I></A> under <A REL=DEFINITION HREF="f_chareq.htm#charEQ"><B>char=</B></A> or <A REL=DEFINITION HREF="f_chareq.htm#char-equal"><B>char-equal</B></A>, as appropriate. <P>
|
|
A string <I>a</I> is less than a string <I>b</I> if in the first position in which they differ the character of <I>a</I> is less than the corresponding character of <I>b</I> according to <A REL=DEFINITION HREF="f_chareq.htm#charLT"><B>char<</B></A> or <A REL=DEFINITION HREF="f_chareq.htm#char-lessp"><B>char-lessp</B></A> as appropriate, or if string <I>a</I> is a proper prefix of string <I>b</I> (of shorter length and matching in all the characters of <I>a</I>). <P>
|
|
The equality functions return a <I>generalized boolean</I> that is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if the strings are equal, or <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> otherwise. <P>
|
|
The inequality functions return a <I>mismatch-index</I> that is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if the strings are not equal, or <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> otherwise. When the <I>mismatch-index</I> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, it is an <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A> representing the first character position at which the two substrings differ, as an offset from the beginning of <I>string1</I>. <P>
|
|
The comparison has one of the following results: <P>
|
|
<P><DL><P>
|
|
<DT><A REL=DEFINITION HREF="#stringEQ"><B>string=</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#stringEQ"><B>string=</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if the supplied substrings are of the same length and contain the <A REL=DEFINITION HREF="26_glo_s.htm#same"><I>same</I></A> characters in corresponding positions; otherwise it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<DT><A REL=DEFINITION HREF="#stringSLEQ"><B>string/=</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#stringSLEQ"><B>string/=</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if the supplied substrings are different; otherwise it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<DT><A REL=DEFINITION HREF="#string-equal"><B>string-equal</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#string-equal"><B>string-equal</B></A> is just like <A REL=DEFINITION HREF="#stringEQ"><B>string=</B></A> except that differences in case are ignored; two characters are considered to be the same if <A REL=DEFINITION HREF="f_chareq.htm#char-equal"><B>char-equal</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> of them. <P>
|
|
<DT><A REL=DEFINITION HREF="#stringLT"><B>string<</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#stringLT"><B>string<</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if substring1 is less than substring2; otherwise it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<DT><A REL=DEFINITION HREF="#stringGT"><B>string></B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#stringGT"><B>string></B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if substring1 is greater than substring2; otherwise it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<DT><A REL=DEFINITION HREF="#string-lessp"><B>string-lessp</B></A>, <A REL=DEFINITION HREF="#string-greaterp"><B>string-greaterp</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#string-lessp"><B>string-lessp</B></A> and <A REL=DEFINITION HREF="#string-greaterp"><B>string-greaterp</B></A> are exactly like <A REL=DEFINITION HREF="#stringLT"><B>string<</B></A> and <A REL=DEFINITION HREF="#stringGT"><B>string></B></A>, respectively, except that distinctions between uppercase and lowercase letters are ignored. It is as if <A REL=DEFINITION HREF="f_chareq.htm#char-lessp"><B>char-lessp</B></A> were used instead of <A REL=DEFINITION HREF="f_chareq.htm#charLT"><B>char<</B></A> for comparing characters. <P>
|
|
<DT><A REL=DEFINITION HREF="#stringLTEQ"><B>string<=</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#stringLTEQ"><B>string<=</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if substring1 is less than or equal to substring2; otherwise it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<DT><A REL=DEFINITION HREF="#stringGTEQ"><B>string>=</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#stringGTEQ"><B>string>=</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if substring1 is greater than or equal to substring2; otherwise it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
<DT><A REL=DEFINITION HREF="#string-not-greaterp"><B>string-not-greaterp</B></A>, <A REL=DEFINITION HREF="#string-not-lessp"><B>string-not-lessp</B></A> <P><DD>
|
|
<A REL=DEFINITION HREF="#string-not-greaterp"><B>string-not-greaterp</B></A> and <A REL=DEFINITION HREF="#string-not-lessp"><B>string-not-lessp</B></A> are exactly like <A REL=DEFINITION HREF="#stringLTEQ"><B>string<=</B></A> and <A REL=DEFINITION HREF="#stringGTEQ"><B>string>=</B></A>, respectively, except that distinctions between uppercase and lowercase letters are ignored. It is as if <A REL=DEFINITION HREF="f_chareq.htm#char-lessp"><B>char-lessp</B></A> were used instead of <A REL=DEFINITION HREF="f_chareq.htm#charLT"><B>char<</B></A> for comparing characters. <P>
|
|
<P></DL><P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(string= "foo" "foo") => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(string= "foo" "Foo") => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(string= "foo" "bar") => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(string= "together" "frog" :start1 1 :end1 3 :start2 2) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(string-equal "foo" "Foo") => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(string= "abcd" "01234abcd9012" :start2 5 :end2 9) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(string< "aaaa" "aaab") => 3
|
|
(string>= "aaaaa" "aaaa") => 4
|
|
(string-not-greaterp "Abcde" "abcdE") => 5
|
|
(string-lessp "012AAAA789" "01aaab6" :start1 3 :end1 7
|
|
:start2 2 :end2 6) => 6
|
|
(string-not-equal "AAAA" "aaaA") => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
</PRE>
|
|
</TT> <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_chareq.htm#charEQ"><B>char=</B></A> <P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_equal.htm#equal"><B>equal</B></A> calls <A REL=DEFINITION HREF="#stringEQ"><B>string=</B></A> if applied to two <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>strings</I></A>. <P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss284.htm">RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL</A><LI> <A REL=CHILD HREF="../Issues/iss332.htm">SUBSEQ-OUT-OF-BOUNDS</A><LI> <A REL=CHILD HREF="../Issues/iss329.htm">STRING-COERCION:MAKE-CONSISTENT</A><P></UL><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>
|