77 lines
8.5 KiB
HTML
77 lines
8.5 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 EVERY, SOME, NOTEVERY, NOTANY</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_cons_1.htm">
|
|
<LINK REL=UP HREF="c_data_a.htm">
|
|
<LINK REL=NEXT HREF="m_and.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_cons_1.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="m_and.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="every"><A NAME="some"><A NAME="notevery"><A NAME="notany"><I>Function</I> <B>EVERY, SOME, NOTEVERY, NOTANY</B></A></A></A></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>every</B> <I>predicate <TT>&rest</TT> sequences+</I> => <I>generalized-boolean</I><P>
|
|
|
|
<B>some</B> <I>predicate <TT>&rest</TT> sequences+</I> => <I>result</I><P>
|
|
|
|
<B>notevery</B> <I>predicate <TT>&rest</TT> sequences+</I> => <I>generalized-boolean</I><P>
|
|
|
|
<B>notany</B> <I>predicate <TT>&rest</TT> sequences+</I> => <I>generalized-boolean</I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>predicate</I>---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 as many <A REL=DEFINITION HREF="26_glo_a.htm#argument"><I>arguments</I></A> as there are <I>sequences</I>. <P>
|
|
<I>sequence</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#sequence"><I>sequence</I></A>. <P>
|
|
<I>result</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>
|
|
<A REL=DEFINITION HREF="#every"><B>every</B></A>, <A REL=DEFINITION HREF="#some"><B>some</B></A>, <A REL=DEFINITION HREF="#notevery"><B>notevery</B></A>, and <A REL=DEFINITION HREF="#notany"><B>notany</B></A> test <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> of <I>sequences</I> for satisfaction of a given <I>predicate</I>. The first argument to <I>predicate</I> is an <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of the first <I>sequence</I>; each succeeding argument is an <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> of a succeeding <I>sequence</I>. <P>
|
|
<I>Predicate</I> is first applied to the elements with index <TT>0</TT> in each of the <I>sequences</I>, and possibly then to the elements with index <TT>1</TT>, and so on, until a termination criterion is met or the end of the shortest of the <I>sequences</I> is reached. <P>
|
|
<A REL=DEFINITION HREF="#every"><B>every</B></A> returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> as soon as any invocation of <I>predicate</I> returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. If the end of a <I>sequence</I> is reached, <A REL=DEFINITION HREF="#every"><B>every</B></A> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. Thus, <A REL=DEFINITION HREF="#every"><B>every</B></A> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if and only if every invocation of <I>predicate</I> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<A REL=DEFINITION HREF="#some"><B>some</B></A> returns the first <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A> value which is returned by an invocation of <I>predicate</I>. If the end of a <I>sequence</I> is reached without any invocation of the <I>predicate</I> returning <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, <A REL=DEFINITION HREF="#some"><B>some</B></A> returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. Thus, <A REL=DEFINITION HREF="#some"><B>some</B></A> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if and only if some invocation of <I>predicate</I> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<A REL=DEFINITION HREF="#notany"><B>notany</B></A> returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> as soon as any invocation of <I>predicate</I> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. If the end of a <I>sequence</I> is reached, <A REL=DEFINITION HREF="#notany"><B>notany</B></A> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. Thus, <A REL=DEFINITION HREF="#notany"><B>notany</B></A> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if and only if it is not the case that any invocation of <I>predicate</I> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<A REL=DEFINITION HREF="#notevery"><B>notevery</B></A> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> as soon as any invocation of <I>predicate</I> returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. If the end of a <I>sequence</I> is reached, <A REL=DEFINITION HREF="#notevery"><B>notevery</B></A> returns <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. Thus, <A REL=DEFINITION HREF="#notevery"><B>notevery</B></A> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A> if and only if it is not the case that every invocation of <I>predicate</I> returns <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(every #'characterp "abc") => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(some #'= '(1 2 3 4 5) '(5 4 3 2 1)) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
(notevery #'< '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) => <A REL=DEFINITION HREF="26_glo_f.htm#false">false</A>
|
|
(notany #'> '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) => <A REL=DEFINITION HREF="26_glo_t.htm#true">true</A>
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Affected By:</B> None.
|
|
<P>
|
|
<P><B>Exceptional Situations:</B><P>
|
|
<P>
|
|
Should signal <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> if its first argument is neither a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> nor a <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> or if any subsequent argument is not a <A REL=DEFINITION HREF="26_glo_p.htm#proper_sequence"><I>proper sequence</I></A>. <P>
|
|
Other exceptional situations are possible, depending on the nature of the <I>predicate</I>. <P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="m_and.htm#and"><B>and</B></A>, <A REL=DEFINITION HREF="m_or.htm#or"><B>or</B></A>, <A REL=CHILD HREF="03_f.htm">Section 3.6 (Traversal Rules and Side Effects)</A> <P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(notany predicate sequence*) == (not (some predicate sequence*))
|
|
(notevery predicate sequence*) == (not (every predicate sequence*))
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss240.htm">MAPPING-DESTRUCTIVE-INTERACTION:EXPLICITLY-VAGUE</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>
|