aboutsummaryrefslogtreecommitdiff
path: root/docs/doc/fill.html
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-08-07 20:41:31 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-08-07 20:41:31 -0400
commit7bf2aa4054b8378a76dff63acdccbcdad91f68e6 (patch)
tree1bff7a2a2b11fa259bc80722fdcb0609768c7718 /docs/doc/fill.html
parent532796eb397c8374e0546de9e4ab70c2955349f3 (diff)
BREAKING: Don't allow First of empty or reshaping empty to non-empty
Diffstat (limited to 'docs/doc/fill.html')
-rw-r--r--docs/doc/fill.html21
1 files changed, 9 insertions, 12 deletions
diff --git a/docs/doc/fill.html b/docs/doc/fill.html
index 5ef9baf1..843e80e8 100644
--- a/docs/doc/fill.html
+++ b/docs/doc/fill.html
@@ -6,7 +6,7 @@
<div class="nav"><a href="https://github.com/mlochbaum/BQN">BQN</a> / <a href="../index.html">main</a> / <a href="index.html">doc</a></div>
<h1 id="fill-elements">Fill elements</h1>
<p>A few array operations need an array element to use when no existing element applies. BQN tries to maintain a &quot;default&quot; element for every array, known as a fill element, for this purpose. If it's known, the fill element is a nested array structure where each atom is either <code><span class='Number'>0</span></code> or <code><span class='String'>' '</span></code>. If no fill is known, a function that requests it results in an error.</p>
-<p>Fills are used by <a href="take.html">Take</a> (<code><span class='Function'>↑</span></code>) when a value in <code><span class='Value'>𝕨</span></code> is larger than the corresponding length in <code><span class='Value'>𝕩</span></code>, by the two <a href="shift.html">Nudge</a> functions (<code><span class='Function'>»«</span></code>) when <code><span class='Value'>𝕩</span></code> is non-empty, and by <a href="pick.html">First</a> (<code><span class='Function'>⊑</span></code>) and <a href="reshape.html">Reshape</a> (<code><span class='Function'>⥊</span></code>) when <code><span class='Value'>𝕩</span></code> is empty. Except for these specific cases, the fill value an array has can't affect the program. The result of <a href="match.html">Match</a> (<code><span class='Function'>≡</span></code>) doesn't depend on fills, and any attempt to compute a fill can't cause side effects.</p>
+<p>Fills are used by <a href="take.html">Take</a> (<code><span class='Function'>↑</span></code>) when a value in <code><span class='Value'>𝕨</span></code> is larger than the corresponding length in <code><span class='Value'>𝕩</span></code>, by the two <a href="shift.html">Nudge</a> functions (<code><span class='Function'>»«</span></code>) when <code><span class='Value'>𝕩</span></code> is non-empty, and by <a href="reshape.html">Reshape</a> (<code><span class='Function'>⥊</span></code>) when <code><span class='Value'>𝕨</span></code> contains <code><span class='Function'>↑</span></code>. Except for these specific cases, the fill value an array has can't affect the program. The result of <a href="match.html">Match</a> (<code><span class='Function'>≡</span></code>) doesn't depend on fills, and any attempt to compute a fill can't cause side effects.</p>
<h2 id="using-fills">Using fills</h2>
<p>For the examples in this section we'll use the fact that an all-number array usually has <code><span class='Number'>0</span></code> as a fill while a string has <code><span class='String'>' '</span></code> (BQN maintains fills alongside array values rather than deriving them from arrays, so it's possible to construct arrays where this isn't true, but this probably wouldn't happen in ordinary code).</p>
<p><a href="take.html">Take</a> (<code><span class='Function'>↑</span></code>) and <a href="shift.html">Nudge</a> (<code><span class='Function'>»«</span></code>) in either direction use the fill for padding, to extend the array past its boundary. For example, <code><span class='Value'>𝕨</span><span class='Function'>↑</span><span class='Value'>𝕩</span></code> will add elements to one side when a number in <code><span class='Function'>|</span><span class='Value'>𝕨</span></code> is larger than the corresponding length in <code><span class='Function'>≢</span><span class='Value'>𝕩</span></code>.</p>
@@ -26,18 +26,15 @@
<span class='Function'>»</span><span class='Bracket'>⟨⟩</span> <span class='Comment'># Fill not needed
</span>⟨⟩
</pre>
-<p><a href="pick.html">First</a> (<code><span class='Function'>⊑</span></code>) and <a href="reshape.html">Reshape</a> (<code><span class='Function'>⥊</span></code>) use the fill when <code><span class='Value'>𝕩</span></code> is empty, and in the case of Reshape only when the result needs to be non-empty.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqRICIiCgo0IOKlisKoIOKfqOKGlTAsICIi4p+pCgow4oC/MyDipYog4p+o4p+pICAjIEZpbGwgbm90IG5lZWRlZA==">↗️</a><pre> <span class='Function'>⊑</span> <span class='String'>&quot;&quot;</span>
-' '
-
- <span class='Number'>4</span> <span class='Function'>⥊</span><span class='Modifier'>¨</span> <span class='Bracket'>⟨</span><span class='Function'>↕</span><span class='Number'>0</span><span class='Separator'>,</span> <span class='String'>&quot;&quot;</span><span class='Bracket'>⟩</span>
-⟨ ⟨ 0 0 0 0 ⟩ " " ⟩
-
- <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>3</span> <span class='Function'>⥊</span> <span class='Bracket'>⟨⟩</span> <span class='Comment'># Fill not needed
-</span>↕0‿3
+<p><a href="reshape.html#computed-lengths">Reshape</a> (<code><span class='Function'>⥊</span></code>) uses the fill when <code><span class='Value'>𝕨</span></code> contains <code><span class='Function'>↑</span></code> and the product of the rest of <code><span class='Value'>𝕨</span></code> doesn't evenly divide the number of elements in <code><span class='Value'>𝕩</span></code>.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oaR4oC/OCDipYogImNvbXBsZXRlcGFydCI=">↗️</a><pre> <span class='Function'>↑</span><span class='Ligature'>‿</span><span class='Number'>8</span> <span class='Function'>⥊</span> <span class='String'>&quot;completepart&quot;</span>
+┌─
+╵"complete
+ part "
+ ┘
</pre>
-<p>If for some reason you need to find an array's fill element, the easiest way is <code><span class='Function'>⊑</span><span class='Number'>0</span><span class='Function'>⥊</span><span class='Value'>a</span></code>.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqRMOKliiJzdHJpbmci">↗️</a><pre> <span class='Function'>⊑</span><span class='Number'>0</span><span class='Function'>⥊</span><span class='String'>&quot;string&quot;</span>
+<p>If for some reason you need to find an array's fill element, the easiest general way is probably <code><span class='Function'>⊑»</span><span class='Number'>1</span><span class='Function'>↑⥊</span><span class='Value'>a</span></code>.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqRwrsx4oaR4qWKInN0cmluZyI=">↗️</a><pre> <span class='Function'>⊑»</span><span class='Number'>1</span><span class='Function'>↑⥊</span><span class='String'>&quot;string&quot;</span>
' '
</pre>
<h2 id="how-fills-are-computed">How fills are computed</h2>