48 lines
2.7 KiB
HTML
48 lines
2.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
|
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
|
<HEAD>
|
|
<TITLE>7.8. Iteration</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value=" Iteration">
|
|
<meta name="keywords" value="clm">
|
|
<meta name="resource-type" value="document">
|
|
<meta name="distribution" value="global">
|
|
<P>
|
|
<b>Common Lisp the Language, 2nd Edition</b>
|
|
<BR> <HR><A NAME=tex2html2596 HREF="node87.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html2594 HREF="node76.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html2588 HREF="node85.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html2598 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html2599 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html2597 HREF="node87.html"> Indefinite Iteration</A>
|
|
<B>Up:</B> <A NAME=tex2html2595 HREF="node76.html"> Control Structure</A>
|
|
<B> Previous:</B> <A NAME=tex2html2589 HREF="node85.html"> Blocks and Exits</A>
|
|
<HR> <P>
|
|
<H1><A NAME=SECTION001180000000000000000>7.8. Iteration</A></H1>
|
|
<P>
|
|
<A NAME=7000>Common</A>
|
|
Lisp provides a number of iteration constructs. The <tt>loop</tt>
|
|
construct provides a trivial iteration facility; it is little more
|
|
than a <tt>progn</tt> with a branch from the bottom back to the top.
|
|
The <tt>do</tt>
|
|
and <tt>do*</tt> constructs provide a general iteration facility
|
|
for controlling the variation of several variables on each cycle.
|
|
For specialized iterations
|
|
over the elements of a list or <i>n</i> consecutive integers, <tt>dolist</tt> and
|
|
<tt>dotimes</tt> are provided. The <tt>tagbody</tt> construct is the most
|
|
general, permitting arbitrary <tt>go</tt> statements within it. (The
|
|
traditional <tt>prog</tt> construct is a synthesis of <tt>tagbody</tt>,
|
|
<tt>block</tt>, and <tt>let</tt>.)
|
|
Most of the iteration constructs permit statically defined non-local exits
|
|
(see <tt>return-from</tt> and <tt>return</tt>).
|
|
<P>
|
|
<HR>
|
|
<UL>
|
|
<LI> <A NAME=tex2html2600 HREF="node87.html#SECTION001181000000000000000"> Indefinite Iteration</A>
|
|
<LI> <A NAME=tex2html2601 HREF="node88.html#SECTION001182000000000000000"> General Iteration</A>
|
|
<LI> <A NAME=tex2html2602 HREF="node89.html#SECTION001183000000000000000"> Simple Iteration Constructs</A>
|
|
<LI> <A NAME=tex2html2603 HREF="node90.html#SECTION001184000000000000000"> Mapping</A>
|
|
<LI> <A NAME=tex2html2604 HREF="node91.html#SECTION001185000000000000000"> The ``Program Feature''</A>
|
|
</UL>
|
|
<HR>
|
|
<P><ADDRESS>
|
|
AI.Repository@cs.cmu.edu
|
|
</ADDRESS>
|
|
</BODY>
|