<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="AsciiDoc 8.6.8">
<title>MLtonVector</title>
<link rel="stylesheet" href="./asciidoc.css" type="text/css">
<link rel="stylesheet" href="./pygments.css" type="text/css">


<script type="text/javascript" src="./asciidoc.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
asciidoc.install();
/*]]>*/
</script>
<link rel="stylesheet" href="./mlton.css" type="text/css"/>
</head>
<body class="article">
<div id="banner">
<div id="banner-home">
<a href="./Home">MLton 20130715</a>
</div>
</div>
<div id="header">
<h1>MLtonVector</h1>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="listingblock">
<div class="content"><div class="highlight"><pre><span class="k">signature</span><span class="w"> </span><span class="n">MLTON_VECTOR</span><span class="w"> </span><span class="p">=</span><span class="w"></span>
<span class="w">   </span><span class="k">sig</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">create</span><span class="p">:</span><span class="w"> </span><span class="n">int</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="p">{</span><span class="n">done</span><span class="p">:</span><span class="w"> </span><span class="n">unit</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">&#39;a</span><span class="w"> </span><span class="n">vector</span><span class="p">,</span><span class="w"></span>
<span class="w">                          </span><span class="n">sub</span><span class="p">:</span><span class="w"> </span><span class="n">int</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">&#39;a</span><span class="p">,</span><span class="w"></span>
<span class="w">                          </span><span class="n">update</span><span class="p">:</span><span class="w"> </span><span class="n">int</span><span class="w"> </span><span class="n">*</span><span class="w"> </span><span class="n">&#39;a</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">unit</span><span class="p">}</span><span class="w"></span>
<span class="w">      </span><span class="k">val</span><span class="w"> </span><span class="n">unfoldi</span><span class="p">:</span><span class="w"> </span><span class="n">int</span><span class="w"> </span><span class="n">*</span><span class="w"> </span><span class="n">&#39;b</span><span class="w"> </span><span class="n">*</span><span class="w"> </span><span class="p">(</span><span class="n">int</span><span class="w"> </span><span class="n">*</span><span class="w"> </span><span class="n">&#39;b</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">&#39;a</span><span class="w"> </span><span class="n">*</span><span class="w"> </span><span class="n">&#39;b</span><span class="p">)</span><span class="w"> </span><span class="p">-&gt;</span><span class="w"> </span><span class="n">&#39;a</span><span class="w"> </span><span class="n">vector</span><span class="w"> </span><span class="n">*</span><span class="w"> </span><span class="n">&#39;b</span><span class="w"></span>
<span class="w">   </span><span class="k">end</span><span class="w"></span>
</pre></div></div></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">create n</span>
</p>
<div class="paragraph"><p>initiates the construction a vector <em>v</em> of length <span class="monospaced">n</span>, returning
functions to manipulate the vector.  The <span class="monospaced">done</span> function may be called
to return the created vector; it is an error to call <span class="monospaced">done</span> before all
entries have been initialized; it is an error to call <span class="monospaced">done</span> after
having called <span class="monospaced">done</span>.  The <span class="monospaced">sub</span> function may be called to return an
initialized vector entry; it is not an error to call <span class="monospaced">sub</span> after
having called <span class="monospaced">done</span>.  The <span class="monospaced">update</span> function may be called to
initialize a vector entry; it is an error to call <span class="monospaced">update</span> after
having called <span class="monospaced">done</span>.  One must initialize vector entries in order
from lowest to highest; that is, before calling <span class="monospaced">update (i, x)</span>, one
must have already called <span class="monospaced">update (j, x)</span> for all <span class="monospaced">j</span> in <span class="monospaced">[0, i)</span>.  The
<span class="monospaced">done</span>, <span class="monospaced">sub</span>, and <span class="monospaced">update</span> functions are all constant-time
operations.</p></div>
</li>
<li>
<p>
<span class="monospaced">unfoldi (n, b, f)</span>
</p>
<div class="paragraph"><p>constructs a vector <em>v</em> of length <span class="monospaced">n</span>, whose elements <em>v<sub>i</sub></em> are
determined by the equations <em>v<sub>0</sub> = b</em> and
<em>(v<sub>i</sub>, b<sub>i+1</sub>) = f (i, b<sub>i</sub>)</em>.</p></div>
</li>
</ul></div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
</div>
<div id="footer-badges">
</div>
</div>
</body>
</html>
