summary refs log tree commit diff
path: root/srfi-214.html
diff options
context:
space:
mode:
Diffstat (limited to 'srfi-214.html')
-rw-r--r--srfi-214.html10
1 files changed, 8 insertions, 2 deletions
diff --git a/srfi-214.html b/srfi-214.html
index 93d2fc0..2341c60 100644
--- a/srfi-214.html
+++ b/srfi-214.html
@@ -153,6 +153,7 @@
 <li><a href="#list-flexvector-reverse-list-flexvector"><code>reverse-list-&gt;flexvector</code></a></li>

 <li><a href="#flexvector-string"><code>flexvector-&gt;string</code></a></li>

 <li><a href="#string-flexvector"><code>string-&gt;flexvector</code></a></li>

+<li><a href="#flexvector-generator"><code>flexvector-&gt;generator</code></a></li>

 <li><a href="#generator-flexvector"><code>generator-&gt;flexvector</code></a></li>

 </ul>

 </li>

@@ -336,18 +337,20 @@ zot
 <div class="copy-wrapper"><pre><code class="language-scheme"><span><span class="mtk1">(flexvector-count&nbsp;even?&nbsp;(flexvector&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">9</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">6</span><span class="mtk1">))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;3</span></span><br><span><span>&nbsp;</span></span><br><span><span class="mtk1">(flexvector-count&nbsp;&lt;&nbsp;(flexvector&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">6</span><span class="mtk1">&nbsp;</span><span class="mtk21">9</span><span class="mtk1">)&nbsp;(flexvector&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;</span><span class="mtk21">6</span><span class="mtk1">&nbsp;</span><span class="mtk21">8</span><span class="mtk1">&nbsp;</span><span class="mtk21">10</span><span class="mtk1">&nbsp;</span><span class="mtk21">12</span><span class="mtk1">))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;2</span></span><br></code></pre></div>

 <h4 id="flexvector-cumulate"><code>flexvector-cumulate</code></h4>

 <p><code>(flexvector-cumulate f knil fv)</code></p>

-<p>Returns a newly-allocated flexvector <code>new</code> with the same length as <code>fv</code>. Each element <code>i</code> of <code>new</code> is set to the result of <code>(f (flexvector-ref new (- i 1)) (flexvector-ref vec i))</code>, except that, for the first call on <code>f</code>, the first argument is <code>knil</code>. The <code>new</code> flexvector is returned.</p>

+<p>Returns a newly-allocated flexvector <code>new</code> with the same length as <code>fv</code>. Each element <code>i</code> of <code>new</code> is set to the result of <code>(f (flexvector-ref new (- i 1)) (flexvector-ref fv i))</code>, except that, for the first call on <code>f</code>, the first argument is <code>knil</code>. The <code>new</code> flexvector is returned.</p>

 <div class="copy-wrapper"><pre><code class="language-scheme"><span><span class="mtk1">(flexvector-cumulate&nbsp;+&nbsp;</span><span class="mtk21">0</span><span class="mtk1">&nbsp;(flexvector&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">9</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">6</span><span class="mtk1">))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;#&lt;flexvector&nbsp;3&nbsp;4&nbsp;8&nbsp;9&nbsp;14&nbsp;23&nbsp;25&nbsp;30&nbsp;36&gt;</span></span><br></code></pre></div>

 <h3 id="searching">Searching</h3>

 <h4 id="flexvector-index-flexvector-index-right"><code>flexvector-index</code>, <code>flexvector-index-right</code></h4>

 <p><code>(flexvector-index pred? fv1 fv2 ...)</code></p>

 <p>Finds and returns the index of the first elements in <code>fv1 fv2 ...</code> that satisfy <code>pred?</code>. If no matching element is found by the end of the shortest flexvector, <code>#f</code> is returned.</p>

 <p><code>flexvector-index-right</code> is similar, but returns the index of the <em>last</em> elements that satisfy <code>pred?</code>, and requires all flexvector arguments to have the same length.</p>

+<p>Given <em>n</em> arguments <code>fv1 fv2...</code>, <code>pred?</code> should be a function that takes <em>n</em> arguments and returns a single value, interpreted as a boolean.</p>
 <div class="copy-wrapper"><pre><code class="language-scheme"><span><span class="mtk1">(flexvector-index&nbsp;even?&nbsp;(flexvector&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">9</span><span class="mtk1">))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;2</span></span><br><span><span>&nbsp;</span></span><br><span><span class="mtk1">(flexvector-index&nbsp;&lt;&nbsp;(flexvector&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">9</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">6</span><span class="mtk1">)&nbsp;(flexvector&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">7</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">8</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;1</span></span><br><span><span>&nbsp;</span></span><br><span><span class="mtk1">(flexvector-index&nbsp;=&nbsp;(flexvector&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">9</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">&nbsp;</span><span class="mtk21">6</span><span class="mtk1">)&nbsp;(flexvector&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">7</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">8</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;#f</span></span><br><span><span>&nbsp;</span></span><br><span><span class="mtk1">(flexvector-index-right&nbsp;&lt;&nbsp;(flexvector&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">5</span><span class="mtk1">)&nbsp;(flexvector&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;</span><span class="mtk21">7</span><span class="mtk1">&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">8</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;3</span></span><br></code></pre></div>

 <h4 id="flexvector-skip-flexvector-skip-right"><code>flexvector-skip</code>, <code>flexvector-skip-right</code></h4>

 <p><code>(flexvector-skip pred? fv1 fv2 ...)</code></p>

 <p>Finds and returns the index of the first elements in <code>fv1 fv2 ...</code> that do <em>not</em> satisfy <code>pred?</code>. If all the values in the flexvectors satisfy <code>pred?</code> until the end of the shortest flexvector, this returns <code>#f</code>.</p>

 <p><code>flexvector-skip-right</code> is similar, but returns the index of the <em>last</em> elements that do not satisfy <code>pred?</code>, and requires all flexvector arguments to have the same length.</p>

+<p>Given <em>n</em> arguments <code>fv1 fv2...</code>, <code>pred?</code> should be a function that takes <em>n</em> arguments and returns a single value, interpreted as a boolean.</p>
 <div class="copy-wrapper"><pre><code class="language-scheme"><span><span class="mtk1">(flexvector-skip&nbsp;number?&nbsp;(flexvector&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;'a&nbsp;'b&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;'c&nbsp;'d))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;2</span></span><br><span><span>&nbsp;</span></span><br><span><span class="mtk1">(flexvector-skip-right&nbsp;number?&nbsp;(flexvector&nbsp;</span><span class="mtk21">1</span><span class="mtk1">&nbsp;</span><span class="mtk21">2</span><span class="mtk1">&nbsp;'a&nbsp;'b&nbsp;</span><span class="mtk21">3</span><span class="mtk1">&nbsp;</span><span class="mtk21">4</span><span class="mtk1">&nbsp;'c&nbsp;'d))</span></span><br><span><span class="mtk4">;=&gt;&nbsp;4</span></span><br></code></pre></div>

 <h4 id="flexvector-binary-search"><code>flexvector-binary-search</code></h4>

 <p><code>(flexvector-binary-search fv value cmp [start [end]])</code></p>

@@ -388,8 +391,11 @@ zot
 <p>Both <code>start</code> and <code>end</code> are clamped to the range [0, <code>(flexvector-length fv)</code>). It is an error if <code>end</code> is less than <code>start</code>.</p>

 <h4 id="string-flexvector"><code>string-&gt;flexvector</code></h4>

 <p><code>(string-&gt;flexvector string [start [end]])</code></p>

-<p>Creates a flexvector containing the elements in <code>string</code> between <code>start</code>, which defaults to -1, and <code>end</code>, which defaults to the length of <code>string</code>.</p>

+<p>Creates a flexvector containing the elements in <code>string</code> between <code>start</code>, which defaults to 0, and <code>end</code>, which defaults to the length of <code>string</code>.</p>

 <p>Both <code>start</code> and <code>end</code> are clamped to the range [0, <code>(string-length string)</code>). It is an error if <code>end</code> is less than <code>start</code>.</p>

+<h4 id="flexvector-generator"><code>flexvector-&gt;generator</code></h4>

+<p><code>(flexvector-&gt;generator fv)</code></p>

+<p>Returns a <a target="_blank" href="https://srfi.schemers.org/srfi-158/srfi-158.html">SRFI 158</a> generator that emits the elements of the flexvector <code>fv</code>, in order. If <code>fv</code> is mutated before the generator is exhausted, the generator's remaining return values are undefined.</p>

 <h4 id="generator-flexvector"><code>generator-&gt;flexvector</code></h4>

 <p><code>(generator-&gt;flexvector gen)</code></p>

 <p>Creates a flexvector containing all elements produced by the <a target="_blank" href="https://srfi.schemers.org/srfi-158/srfi-158.html">SRFI 158</a> generator <code>gen</code>.</p>