/usr/share/mozart/doc/base/loop.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>10.2 Loops</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node13.html#section.control.general"><< Prev</A></TD><TD><A href="node12.html">- Up -</A></TD><TD><A href="time.html#section.control.time">Next >></A></TD></TR></TABLE><DIV id="section.control.loops"><H2><A name="section.control.loops">10.2 Loops</A></H2><P> The module <A name="label698"></A><SPAN class="index"><CODE>Loop</CODE></SPAN> contains procedures that represent recursive versions of common iteration schemes with integers. However, for most common iteration patterns, the <CODE><SPAN class="keyword">for</SPAN></CODE> loop offers a nicer alternative (see <A href="../loop/index.html">``Loop Support''</A>). </P><DL><DT><A name="label699"></A><SPAN class="index"><CODE>For</CODE></SPAN> <A name="label700"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Loop<SPAN class="keyword">.</SPAN><SPAN class="string">'for'</SPAN> </CODE><CODE>+<I>I1</I></CODE><CODE> </CODE><CODE>+<I>I2</I></CODE><CODE> </CODE><CODE>+<I>I3</I></CODE><CODE> </CODE><CODE>+<I>P</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>applies the unary procedure <CODE><I>P</I></CODE> to integers from <CODE><I>I1</I></CODE> to <CODE><I>I2</I></CODE> proceeding in steps of size <CODE><I>I3</I></CODE>. For example, </P><BLOCKQUOTE class="code"><CODE>{For 1 11 3 Browse}</CODE></BLOCKQUOTE><P> displays the numbers <CODE>1</CODE>, <CODE>4</CODE>, <CODE>7</CODE>, and <CODE>10</CODE> in the browser window, whereas </P><BLOCKQUOTE class="code"><CODE>{For 11 1 <SPAN class="keyword">~</SPAN>3 Browse}</CODE></BLOCKQUOTE><P> displays the numbers <CODE>11</CODE>, <CODE>8</CODE>, <CODE>5</CODE>, and <CODE>2</CODE>. </P></DD><DT><A name="label701"></A><SPAN class="index"><CODE>ForThread</CODE></SPAN> <A name="label702"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Loop<SPAN class="keyword">.</SPAN>forThread </CODE><CODE>+<I>I1</I></CODE><CODE> </CODE><CODE>+<I>I2</I></CODE><CODE> </CODE><CODE>+<I>I3</I></CODE><CODE> </CODE><CODE>+<I>P</I></CODE><CODE> </CODE><CODE><I>X</I></CODE><CODE> </CODE><CODE>?<I>Y</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>applies the ternary procedure <CODE><I>P</I></CODE> to integers from <CODE><I>I1</I></CODE> to <CODE><I>I2</I></CODE> proceeding in steps of size <CODE><I>I3</I></CODE> while threading an additional accumulator argument through the iteration. The procedure <CODE><I>P</I></CODE> takes the accumulator argument (initially set to <CODE><I>X</I></CODE>) and the loop index and returns an updated accumulator. </P><P> For example, </P><BLOCKQUOTE class="code"><CODE>{ForThread 1 5 1 <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Is I} I<SPAN class="keyword">*</SPAN>I<SPAN class="keyword">|</SPAN>Is <SPAN class="keyword">end</SPAN> nil}</CODE></BLOCKQUOTE><P> yields the list <CODE>[25 16 9 4 1]</CODE> as output, whereas </P><BLOCKQUOTE class="code"><CODE>{ForThread 5 1 <SPAN class="keyword">~</SPAN>1 <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Is I} I<SPAN class="keyword">*</SPAN>I<SPAN class="keyword">|</SPAN>Is <SPAN class="keyword">end</SPAN> nil}</CODE></BLOCKQUOTE><P> yields <CODE>[1 4 9 16 25]</CODE> as output. </P><P> Note that <CODE>ForThread</CODE> is similar to <CODE>FoldL</CODE> (see <A href="list.html#section.records.lists">Section 6.3</A>). </P></DD><DT><CODE>multiFor</CODE> <A name="label704"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Loop<SPAN class="keyword">.</SPAN>multiFor </CODE><CODE>+<I>Xs</I></CODE><CODE> </CODE><CODE>+<I>P</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>generalizes <CODE>For</CODE> (see above) to the case of multiple nested loops. </P><P> <CODE><I>Xs</I></CODE> is a list containing tuples of the form <CODE><I>I1</I></CODE><CODE><SPAN class="keyword">#</SPAN></CODE><CODE><I>I2</I></CODE><CODE><SPAN class="keyword">#</SPAN></CODE><CODE><I>I3</I></CODE> specifying a loop by its start value <CODE><I>I1</I></CODE>, upper limit <CODE><I>I2</I></CODE> and step size <CODE><I>I3</I></CODE>. </P><P> For example, </P><BLOCKQUOTE class="code"><CODE>{Loop<SPAN class="keyword">.</SPAN>multiFor [1<SPAN class="keyword">#</SPAN>5<SPAN class="keyword">#</SPAN>1 10<SPAN class="keyword">#</SPAN>20<SPAN class="keyword">#</SPAN>2] Browse}</CODE></BLOCKQUOTE><P> displays the lists <CODE>[1 10]</CODE>, <CODE>[1 12]</CODE>, ..., <CODE>[5 20]</CODE> in the browser. </P></DD><DT><CODE>multiForThread</CODE> <A name="label706"></A> </DT><DD><BLOCKQUOTE class="synopsis"><P><CODE>{Loop<SPAN class="keyword">.</SPAN>multiForThread </CODE><CODE>+<I>Xs</I></CODE><CODE> </CODE><CODE>+<I>P</I></CODE><CODE> </CODE><CODE><I>X</I></CODE><CODE> </CODE><CODE>?<I>Y</I></CODE><CODE>}</CODE> </P></BLOCKQUOTE></DD><DD><P>generalizes <CODE>ForThread</CODE> (see above) to the case of multiple nested loops. </P><P> <CODE><I>Xs</I></CODE> is a list containing tuples of the form <CODE><I>I1</I></CODE><CODE><SPAN class="keyword">#</SPAN></CODE><CODE><I>I2</I></CODE><CODE><SPAN class="keyword">#</SPAN></CODE><CODE><I>I3</I></CODE> specifying a loop by its start value <CODE><I>I1</I></CODE>, upper limit <CODE><I>I2</I></CODE> and step size <CODE><I>I3</I></CODE>. </P><P> For example, </P><BLOCKQUOTE class="code"><CODE>{Loop<SPAN class="keyword">.</SPAN>multiForThread [1<SPAN class="keyword">#</SPAN>2<SPAN class="keyword">#</SPAN>1 5<SPAN class="keyword">#</SPAN>4<SPAN class="keyword">#~</SPAN>1]<BR> <SPAN class="keyword">fun</SPAN><SPAN class="variablename"> </SPAN>{<SPAN class="functionname">$</SPAN> Is [I J]}<BR> I<SPAN class="keyword">#</SPAN>J<SPAN class="keyword">|</SPAN>Is<BR> <SPAN class="keyword">end</SPAN> nil}</CODE></BLOCKQUOTE><P> yields the list <CODE>[2<SPAN class="keyword">#</SPAN>4 2<SPAN class="keyword">#</SPAN>5 1<SPAN class="keyword">#</SPAN>4 1<SPAN class="keyword">#</SPAN>5]</CODE> as output. </P></DD></DL><P> </P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node13.html#section.control.general"><< Prev</A></TD><TD><A href="node12.html">- Up -</A></TD><TD><A href="time.html#section.control.time">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A> and <A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|