1
0
Fork 0
cl-sites/novaspec.org/cl/f_every.html
2025-02-05 18:52:26 +01:00

601 lines
No EOL
12 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>every, some, notevery, notany | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_every.html"
><LINK REL="next" HREF="f_and.html" TYPE="text/html" TITLE="and"
><LINK REL="prev" HREF="f_constantly.html" TYPE="text/html" TITLE="constantly"
><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_every.html"
>every, some, notevery, notany</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_constantly.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_and.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="every, some, notevery, notany"
></SPAN
><B
>every, some, notevery, notany</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
>every</B
> <SPAN CLASS="cmssi"
>predicate</SPAN
> <SPAN CLASS="cmtt"
>&amp;rest</SPAN
> <SPAN CLASS="cmssi"
>sequences</SPAN
><SUP CLASS="sup"
><SPAN CLASS="cmssi"
>+</SPAN
></SUP
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmssi"
>generalized-boolean</SPAN
></P
><P CLASS="j"
><B
>some</B
> <SPAN CLASS="cmssi"
>predicate</SPAN
> <SPAN CLASS="cmtt"
>&amp;rest</SPAN
> <SPAN CLASS="cmssi"
>sequences</SPAN
><SUP CLASS="sup"
><SPAN CLASS="cmssi"
>+</SPAN
></SUP
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmssi"
>result</SPAN
></P
><P CLASS="j"
><B
>notevery</B
> <SPAN CLASS="cmssi"
>predicate</SPAN
> <SPAN CLASS="cmtt"
>&amp;rest</SPAN
> <SPAN CLASS="cmssi"
>sequences</SPAN
><SUP CLASS="sup"
><SPAN CLASS="cmssi"
>+</SPAN
></SUP
> <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="cmssi"
>generalized-boolean</SPAN
></P
><P CLASS="j"
><B
>notany</B
> <SPAN CLASS="cmssi"
>predicate</SPAN
> <SPAN CLASS="cmtt"
>&amp;rest</SPAN
> <SPAN CLASS="cmssi"
>sequences</SPAN
><SUP CLASS="sup"
><SPAN CLASS="cmssi"
>+</SPAN
></SUP
> <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"
>predicate</VAR
> &#8212; a <A HREF="26_1_Glossary.html#designator"
><EM CLASS="term"
>designator</EM
></A
> for a <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> of as many <A HREF="26_1_Glossary.html#argument"
><EM CLASS="term"
>arguments</EM
></A
> as there are <VAR CLASS="param"
>sequences</VAR
>. </P
><P CLASS="j"
><VAR CLASS="param"
>sequence</VAR
> &#8212; a <A HREF="26_1_Glossary.html#sequence"
><EM CLASS="term"
>sequence</EM
></A
>. </P
><P CLASS="j"
><VAR CLASS="param"
>result</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"
><A HREF="f_every.html" CLASS="funref"
><B
>every</B
></A
>, <A HREF="f_every.html" CLASS="funref"
><B
>some</B
></A
>, <A HREF="f_every.html" CLASS="funref"
><B
>notevery</B
></A
>, and <A HREF="f_every.html" CLASS="funref"
><B
>notany</B
></A
> test <A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>elements</EM
></A
> of <VAR CLASS="param"
>sequences</VAR
> for satisfaction of a given <VAR CLASS="param"
>predicate</VAR
>. The first argument to <VAR CLASS="param"
>predicate</VAR
> is an <A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>element</EM
></A
> of the first <VAR CLASS="param"
>sequence</VAR
>; each succeeding argument is an <A HREF="26_1_Glossary.html#element"
><EM CLASS="term"
>element</EM
></A
> of a succeeding <VAR CLASS="param"
>sequence</VAR
>. </P
><P CLASS="j"
><VAR CLASS="param"
>Predicate</VAR
> is first applied to the elements with index <CODE CLASS="f"
>0</CODE
> in each of the <VAR CLASS="param"
>sequences</VAR
>, and possibly then to the elements with index <CODE CLASS="f"
>1</CODE
>, and so on, until a termination criterion is met or the end of the shortest of the <VAR CLASS="param"
>sequences</VAR
> is reached. </P
><P CLASS="j"
><A HREF="f_every.html" CLASS="funref"
><B
>every</B
></A
> returns <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
> as soon as any invocation of <VAR CLASS="param"
>predicate</VAR
> returns <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>. If the end of a <VAR CLASS="param"
>sequence</VAR
> is reached, <A HREF="f_every.html" CLASS="funref"
><B
>every</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>. Thus, <A HREF="f_every.html" CLASS="funref"
><B
>every</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> if and only if every invocation of <VAR CLASS="param"
>predicate</VAR
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>. </P
><P CLASS="j"
><A HREF="f_every.html" CLASS="funref"
><B
>some</B
></A
> returns the first <A HREF="26_1_Glossary.html#non-nil"
><EM CLASS="term"
>non-nil</EM
></A
> value which is returned by an invocation of <VAR CLASS="param"
>predicate</VAR
>. If the end of a <VAR CLASS="param"
>sequence</VAR
> is reached without any invocation of the <VAR CLASS="param"
>predicate</VAR
> returning <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, <A HREF="f_every.html" CLASS="funref"
><B
>some</B
></A
> returns <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>. Thus, <A HREF="f_every.html" CLASS="funref"
><B
>some</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> if and only if some invocation of <VAR CLASS="param"
>predicate</VAR
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>. </P
><P CLASS="j"
><A HREF="f_every.html" CLASS="funref"
><B
>notany</B
></A
> returns <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
> as soon as any invocation of <VAR CLASS="param"
>predicate</VAR
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>. If the end of a <VAR CLASS="param"
>sequence</VAR
> is reached, <A HREF="f_every.html" CLASS="funref"
><B
>notany</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>. Thus, <A HREF="f_every.html" CLASS="funref"
><B
>notany</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> if and only if it is not the case that any invocation of <VAR CLASS="param"
>predicate</VAR
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>. </P
><P CLASS="j"
><A HREF="f_every.html" CLASS="funref"
><B
>notevery</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> as soon as any invocation of <VAR CLASS="param"
>predicate</VAR
> returns <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>. If the end of a <VAR CLASS="param"
>sequence</VAR
> is reached, <A HREF="f_every.html" CLASS="funref"
><B
>notevery</B
></A
> returns <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>. Thus, <A HREF="f_every.html" CLASS="funref"
><B
>notevery</B
></A
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
> if and only if it is not the case that every invocation of <VAR CLASS="param"
>predicate</VAR
> returns <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
>(every #'characterp "abc") <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(some #'= '(1 2 3 4 5) '(5 4 3 2 1)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>
(notevery #'&lt; '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>
(notany #'&gt; '(1 2 3 4) '(5 6 7 8) '(9 10 11 12)) <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
>Exceptional Situations</B
></DT
><DD
><P CLASS="j"
>Should signal <A HREF="t_type-error.html" CLASS="typeref"
><B
>type-error</B
></A
> if its first argument is neither a <A HREF="26_1_Glossary.html#symbol"
><EM CLASS="term"
>symbol</EM
></A
> nor a <A HREF="26_1_Glossary.html#function"
><EM CLASS="term"
>function</EM
></A
> or if any subsequent argument is not a <A HREF="26_1_Glossary.html#proper_sequence"
><EM CLASS="term"
>proper sequence</EM
></A
>. </P
><P CLASS="j"
>Other exceptional situations are possible, depending on the nature of the <VAR CLASS="param"
>predicate</VAR
>.</P
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_and.html" CLASS="macref"
><B
>and</B
></A
>, <A HREF="f_or.html" CLASS="macref"
><B
>or</B
></A
>, <A HREF="3_6_Traversal_Rules_and_Side_Effects.html#sec_3_6" CLASS="secref"
><SPAN CLASS="cmr"
>Section</SPAN
> <SPAN CLASS="cmr"
>3.6</SPAN
> <SPAN CLASS="cmr"
>(Traversal</SPAN
> <SPAN CLASS="cmr"
>Rules</SPAN
> <SPAN CLASS="cmr"
>and</SPAN
> <SPAN CLASS="cmr"
>Side</SPAN
> <SPAN CLASS="cmr"
>Effects)</SPAN
></A
></P
></DD
><DT
><B
>Notes</B
></DT
><DD
><PRE CLASS="screen"
>(notany <VAR CLASS="param"
>predicate</VAR
> <SPAN CLASS="cmsy"
>{</SPAN
><VAR CLASS="param"
>sequence</VAR
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>*</SPAN
>) <SPAN CLASS="cmsy"
><SPAN STYLE="font-size:16px;vertical-align:-2px"
>&#8801;</SPAN
></SPAN
> (not (some <VAR CLASS="param"
>predicate</VAR
> <SPAN CLASS="cmsy"
>{</SPAN
><VAR CLASS="param"
>sequence</VAR
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>*</SPAN
>))
(notevery <VAR CLASS="param"
>predicate</VAR
> <SPAN CLASS="cmsy"
>{</SPAN
><VAR CLASS="param"
>sequence</VAR
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>*</SPAN
>) <SPAN CLASS="cmsy"
><SPAN STYLE="font-size:16px;vertical-align:-2px"
>&#8801;</SPAN
></SPAN
> (not (every <VAR CLASS="param"
>predicate</VAR
> <SPAN CLASS="cmsy"
>{</SPAN
><VAR CLASS="param"
>sequence</VAR
><SPAN CLASS="cmsy"
>}</SPAN
><SPAN CLASS="cmr"
>*</SPAN
>))</PRE
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_constantly.html" CLASS="prev"
>&#8592;</A
><A HREF="f_and.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
>