51 lines
8.1 KiB
HTML
51 lines
8.1 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: Section 17.2.1</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="17_b.htm">
|
|
<LINK REL=UP HREF="17_b.htm">
|
|
<LINK REL=NEXT HREF="17_baa.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="17_b.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="17_b.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="17_baa.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<H2>
|
|
17.2.1 Satisfying a Two-Argument Test</H2> <P>
|
|
When an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> O is being considered iteratively against each <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> Ei of a <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></A> S by an <A REL=DEFINITION HREF="26_glo_o.htm#operator"><I>operator</I></A> F listed in the next figure, it is sometimes useful to control the way in which the presence of O is tested in S is tested by F. This control is offered on the basis of a <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> designated with either a <TT>:test</TT> or <TT>:test-not</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A>. <P>
|
|
<PRE>
|
|
<A REL=DEFINITION HREF="f_adjoin.htm#adjoin">adjoin</A> <A REL=DEFINITION HREF="f_set_ex.htm#nset-exclusive-or">nset-exclusive-or</A> <A REL=DEFINITION HREF="f_search.htm#search">search</A>
|
|
<A REL=DEFINITION HREF="f_assocc.htm#assoc">assoc</A> <A REL=DEFINITION HREF="f_sublis.htm#nsublis">nsublis</A> <A REL=DEFINITION HREF="f_set_di.htm#set-difference">set-difference</A>
|
|
<A REL=DEFINITION HREF="f_countc.htm#count">count</A> <A REL=DEFINITION HREF="f_substc.htm#nsubst">nsubst</A> <A REL=DEFINITION HREF="f_set_ex.htm#set-exclusive-or">set-exclusive-or</A>
|
|
<A REL=DEFINITION HREF="f_rm_rm.htm#delete">delete</A> <A REL=DEFINITION HREF="f_sbs_s.htm#nsubstitute">nsubstitute</A> <A REL=DEFINITION HREF="f_sublis.htm#sublis">sublis</A>
|
|
<A REL=DEFINITION HREF="f_find_.htm#find">find</A> <A REL=DEFINITION HREF="f_unionc.htm#nunion">nunion</A> <A REL=DEFINITION HREF="f_subset.htm#subsetp">subsetp</A>
|
|
<A REL=DEFINITION HREF="f_isec_.htm#intersection">intersection</A> <A REL=DEFINITION HREF="f_pos_p.htm#position">position</A> <A REL=DEFINITION HREF="f_substc.htm#subst">subst</A>
|
|
<A REL=DEFINITION HREF="a_member.htm#member">member</A> <A REL=DEFINITION HREF="m_pshnew.htm#pushnew">pushnew</A> <A REL=DEFINITION HREF="f_sbs_s.htm#substitute">substitute</A>
|
|
<A REL=DEFINITION HREF="f_mismat.htm#mismatch">mismatch</A> <A REL=DEFINITION HREF="f_rassoc.htm#rassoc">rassoc</A> <A REL=DEFINITION HREF="f_tree_e.htm#tree-equal">tree-equal</A>
|
|
<A REL=DEFINITION HREF="f_isec_.htm#nintersection">nintersection</A> <A REL=DEFINITION HREF="f_rm_rm.htm#remove">remove</A> <A REL=DEFINITION HREF="f_unionc.htm#union">union</A>
|
|
<A REL=DEFINITION HREF="f_set_di.htm#nset-difference">nset-difference</A> <A REL=DEFINITION HREF="f_rm_dup.htm#remove-duplicates">remove-duplicates</A>
|
|
</PRE>
|
|
<P><B>Figure 17-2. Operators that have Two-Argument Tests to be Satisfied</B> <P>
|
|
The object O might not be compared directly to Ei. If a <TT>:key</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> is provided, it is a <A REL=DEFINITION HREF="26_glo_d.htm#designator"><I>designator</I></A> for a <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> of one <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> to be called with each Ei as an <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A>, and <I>yielding</I> an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> Zi to be used for comparison. (If there is no <TT>:key</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A>, Zi is Ei.) <P>
|
|
The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> designated by the <TT>:key</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> is never called on O itself. However, if the function operates on multiple sequences (e.g., as happens in <A REL=DEFINITION HREF="f_set_di.htm#set-difference"><B>set-difference</B></A>), O will be the result of calling the <TT>:key</TT> function on an <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of the other sequence. <P>
|
|
A <TT>:test</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A>, if supplied to F, is a <A REL=DEFINITION HREF="26_glo_d.htm#designator"><I>designator</I></A> for a <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> of two <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>arguments</I></A>, O and Zi. An Ei is said (or, sometimes, an O and an Ei are said) to <A REL=DEFINITION HREF="26_glo_s.htm#satisfy_the_test"><I>satisfy the test</I></A> if this <TT>:test</TT> <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> returns a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A> representing <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
A <TT>:test-not</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A>, if supplied to F, is <A REL=DEFINITION HREF="26_glo_d.htm#designator"><I>designator</I></A> for a <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> of two <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>arguments</I></A>, O and Zi. An Ei is said (or, sometimes, an O and an Ei are said) to <A REL=DEFINITION HREF="26_glo_s.htm#satisfy_the_test"><I>satisfy the test</I></A> if this <TT>:test-not</TT> <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> returns a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A> representing <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
|
|
If neither a <TT>:test</TT> nor a <TT>:test-not</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> is supplied, it is as if a <TT>:test</TT> argument of <TT>#'eql</TT> was supplied. <P>
|
|
The consequences are unspecified if both a <TT>:test</TT> and a <TT>:test-not</TT> <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>argument</I></A> are supplied in the same <A REL=DEFINITION HREF="26_glo_c.htm#call"><I>call</I></A> to F. <P>
|
|
|
|
|
|
<A REL=CHILD HREF="17_baa.htm"><H2>
|
|
17.2.1.1 Examples of Satisfying a Two-Argument Test</H2></A><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>
|