aboutsummaryrefslogtreecommitdiff
path: root/docs/doc/reshape.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doc/reshape.html')
-rw-r--r--docs/doc/reshape.html12
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/doc/reshape.html b/docs/doc/reshape.html
index 58b7dece..e9523103 100644
--- a/docs/doc/reshape.html
+++ b/docs/doc/reshape.html
@@ -4,7 +4,7 @@
<title>BQN: Deshape and Reshape</title>
</head>
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">doc</a></div>
-<h1 id="deshape-and-reshape">Deshape and Reshape</h1>
+<h1 id="deshape-and-reshape"><a class="header" href="#deshape-and-reshape">Deshape and Reshape</a></h1>
<svg viewBox='-64 -15 608 377'>
<g fill='currentColor' stroke-linecap='round' font-family='BQN,monospace'>
<rect class='code' stroke-width='1.5' rx='12' x='0' y='0' width='480' height='347'/>
@@ -60,7 +60,7 @@
<p>The glyph <code><span class='Function'>⥊</span></code> indicates BQN's facilities to reflow the data in an array, giving it a different shape. Its monadic form, Deshape, simply removes all shape information, returning a list of all the elements from the array in reading order. With a left argument, <code><span class='Function'>⥊</span></code> is called Reshape and is a more versatile tool for rearranging the data in an array into the desired shape.</p>
<p>Because of its dependence on the reading order of an array, Reshape is less fundamental than other array operations. Using Reshape in the central computations of a program can be a sign of imperfect usage of arrays. For example, it may be useful to use Reshape to create a constant array or repeat a sequence of values several times, but the same task might also be accomplished more simply with <a href="map.html#table">Table</a> <code><span class='Modifier'>⌜</span></code>, or by taking advantage of <a href="leading.html#leading-axis-agreement">leading axis agreement</a> in arithmetic primitives.</p>
-<h2 id="deshape">Deshape</h2>
+<h2 id="deshape"><a class="header" href="#deshape">Deshape</a></h2>
<p>The result of Deshape is a list containing the same elements as the argument.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIGEg4oaQICvijJzCtCDin6gxMDDigL8yMDAsIDMw4oC/NDAsIDXigL824oC/N+KfqQoK4qWKIGE=">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>a</span> <span class='Gets'>←</span> <span class='Function'>+</span><span class='Modifier'>⌜´</span> <span class='Bracket'>⟨</span><span class='Number'>100</span><span class='Ligature'>‿</span><span class='Number'>200</span><span class='Separator'>,</span> <span class='Number'>30</span><span class='Ligature'>‿</span><span class='Number'>40</span><span class='Separator'>,</span> <span class='Number'>5</span><span class='Ligature'>‿</span><span class='Number'>6</span><span class='Ligature'>‿</span><span class='Number'>7</span><span class='Bracket'>⟩</span>
┌─
@@ -94,10 +94,10 @@
<span class='Function'>≍</span> <span class='Number'>2</span>
⟨ 2 ⟩
</pre>
-<h2 id="reshape">Reshape</h2>
+<h2 id="reshape"><a class="header" href="#reshape">Reshape</a></h2>
<p>While Deshape removes all shape information from its argument array, Reshape adds shape information back based on the left argument. Reshape ignores the shape of its original argument, treating it like a list of elements as though it were deshaped initially.</p>
<p>The left argument of Reshape gives the shape of the result, except that one entry can be left unspecified for BQN to fill in. We'll look at the cases where a full shape is given first.</p>
-<h3 id="matching-lengths">Matching lengths</h3>
+<h3 id="matching-lengths"><a class="header" href="#matching-lengths">Matching lengths</a></h3>
<p>If the number of elements implied by the given shape—that is, <code><span class='Function'>×</span><span class='Modifier'>´</span><span class='Value'>𝕨</span></code>—is equal to the number of elements in <code><span class='Value'>𝕩</span></code>, then <code><span class='Value'>𝕩</span></code> is simply rearranged to match that shape. The element list is kept the same, so that the deshaped result matches the deshaped right argument.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=YQoKNuKAvzIg4qWKIGEKCijipYphKSDiiaEg4qWKIDbigL8y4qWKYQ==">↗️</a><pre> <span class='Value'>a</span>
┌─
@@ -133,7 +133,7 @@
7 8 9 10 11 12 13
</pre>
-<h3 id="non-matching-lengths">Non-matching lengths</h3>
+<h3 id="non-matching-lengths"><a class="header" href="#non-matching-lengths">Non-matching lengths</a></h3>
<p>If <code><span class='Value'>𝕨</span></code> implies a smaller number of elements than are present initially, then only the initial elements of <code><span class='Value'>𝕩</span></code> are used. Here the result stops at <code><span class='Number'>237</span></code>, three-quarters of the way through <code><span class='Value'>a</span></code>, because at that point the result is filled up.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=M+KAvzMg4qWKIGE=">↗️</a><pre> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>3</span> <span class='Function'>⥊</span> <span class='Value'>a</span>
┌─
@@ -160,7 +160,7 @@ ERROR
<span class='Number'>5</span> <span class='Function'>⥊</span> <span class='Function'>&lt;</span> <span class='String'>&quot;string&quot;</span>
⟨ "string" "string" "string" "string" "string" ⟩
</pre>
-<h3 id="computed-lengths">Computed lengths</h3>
+<h3 id="computed-lengths"><a class="header" href="#computed-lengths">Computed lengths</a></h3>
<p>What if you want to reshape an array into, say, rows of length 2, but don't want to write out the number of rows?</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oiY4oC/MiDipYogImFBZUVpSW9PdVUi">↗️</a><pre> <span class='Modifier2'>∘</span><span class='Ligature'>‿</span><span class='Number'>2</span> <span class='Function'>⥊</span> <span class='String'>&quot;aAeEiIoOuU&quot;</span>
┌─