aboutsummaryrefslogtreecommitdiff
path: root/docs/doc/couple.html
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-07-05 22:20:19 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-07-05 22:20:19 -0400
commitc96289046dbd42678c10d03ceb5734737392bf4c (patch)
treefc897441ab6de8f5453aceb0424ff3969c696d4f /docs/doc/couple.html
parent3734638f2f04b5e298dca250f589ae1e4913f88f (diff)
Inter-documentation links and minor editing
Diffstat (limited to 'docs/doc/couple.html')
-rw-r--r--docs/doc/couple.html4
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/doc/couple.html b/docs/doc/couple.html
index fa9b905a..1e55a233 100644
--- a/docs/doc/couple.html
+++ b/docs/doc/couple.html
@@ -65,7 +65,7 @@
<span class='Function'>∾</span> <span class='Function'>⥊</span> <span class='Function'>⥊</span><span class='Modifier'>¨</span> <span class='Value'>a</span>
"ABrstABuvwABxyzCDrstCDuvwCDxyz"
</pre>
-<p>The way this happens, and the constraint that all inner arrays have the same shape, is closely connected to the concept of an array, and like Table <code><span class='Modifier'>⌜</span></code>, Merge might be considered a fundamental way to build up multidimensional arrays from lists. In both cases rank-0 or unit arrays are somewhat special. They are the identity element of a function with Table, and can be produced by Merge inverse, <code><span class='Function'>&gt;</span><span class='Modifier'>⁼</span></code> <strong>on a list</strong>, which forces either the outer or inner shape to be empty (BQN chooses <code><span class='Function'>&gt;</span><span class='Modifier'>⁼</span></code> to be <code><span class='Function'>&lt;</span></code>, but only on an array, as <code><span class='Function'>&gt;</span></code> cannot produce non-arrays). Merge has another catch as well: it cannot produce arrays with a <code><span class='Number'>0</span></code> in the shape, except at the end, without some sort of prototype system.</p>
+<p>The way this happens, and the constraint that all inner arrays have the same shape, is closely connected to the concept of an array, and like <a href="map.html#table">Table</a> <code><span class='Modifier'>⌜</span></code>, Merge might be considered a fundamental way to build up multidimensional arrays from lists. In both cases rank-0 or <a href="enclose.html#whats-a-unit">unit</a> arrays are somewhat special. They are the <a href="fold.html#identity-values">identity value</a> of a function with Table, and can be produced by Merge inverse, <code><span class='Function'>&gt;</span><span class='Modifier'>⁼</span></code> <strong>on a list</strong>, which forces either the outer or inner shape to be empty (BQN chooses <code><span class='Function'>&gt;</span><span class='Modifier'>⁼</span></code> to be <code><span class='Function'>&lt;</span></code>, but only on an array, as <code><span class='Function'>&gt;</span></code> cannot produce non-arrays). Merge has another catch as well: it cannot produce arrays with a <code><span class='Number'>0</span></code> in the shape, except at the end, unless fills can be specified.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIGUg4oaQIOKfqOKfqcKoIOKGlTMK4omiID4gZQriiaIgPiA+IGU=">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>e</span> <span class='Gets'>←</span> <span class='Bracket'>⟨⟩</span><span class='Modifier'>¨</span> <span class='Function'>↕</span><span class='Number'>3</span>
⟨ ⟨⟩ ⟨⟩ ⟨⟩ ⟩
<span class='Function'>≢</span> <span class='Function'>&gt;</span> <span class='Value'>e</span>
@@ -75,7 +75,7 @@
</pre>
<p>Above we start with a list of three empty arrays. After merging once we get a shape <code><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>0</span></code> array, sure, but what happens next? The shape added by another merge is the shared shape of that array's elements—and there aren't any! If the nested list kept some type information around then we might know, but extra type information is essentially how lists pretend to be arrays. True dynamic lists simply can't represent multidimensional arrays with a <code><span class='Number'>0</span></code> in the middle of the shape. In this sense, arrays are a richer model than nested lists.</p>
<h2 id="coupling-units">Coupling units</h2>
-<p>A note on the topic of Solo and Couple applied to units. As always, one axis will be added, so that the result is a list (strangely, J's <a href="https://code.jsoftware.com/wiki/Vocabulary/commaco#dyadic">laminate</a> differs from Couple in this one case, as it will add an axis to get a shape <code><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>1</span></code> result). For Solo, this is interchangeable with Deshape (<code><span class='Function'>⥊</span></code>), and either primitive might be chosen for stylistic reasons. For Couple, it is equivalent to Join-to (<code><span class='Function'>∾</span></code>), but this is an irregular form of Join-to because it is the only case where Join-to adds an axis to both arguments instead of just one. Couple should be preferred in this case.</p>
+<p>A note on the topic of Solo and Couple applied to units. As always, one axis will be added, so that the result is a list (strangely, J's <a href="https://code.jsoftware.com/wiki/Vocabulary/commaco#dyadic">laminate</a> differs from Couple in this one case, as it will add an axis to get a shape <code><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>1</span></code> result). For Solo, this is interchangeable with <a href="reshape.html">Deshape</a> (<code><span class='Function'>⥊</span></code>), and either primitive might be chosen for stylistic reasons. For Couple, it is equivalent to <a href="join.html">Join-to</a> (<code><span class='Function'>∾</span></code>), but this is an irregular form of Join-to because it is the only case where Join-to adds an axis to both arguments instead of just one. Couple should be preferred in this case.</p>
<p>The pair function, which creates a list from its arguments, can be written <code><span class='Function'>Pair</span> <span class='Gets'>←</span> <span class='Function'>≍</span><span class='Modifier2'>○</span><span class='Function'>&lt;</span></code>, while <code><span class='Function'>≍</span></code> in either valence is <code><span class='Function'>&gt;</span><span class='Modifier2'>∘</span><span class='Function'>Pair</span></code>. As an interesting consequence, <code><span class='Function'>≍</span> <span class='Gets'>←→</span> <span class='Function'>&gt;</span><span class='Modifier2'>∘</span><span class='Function'>≍</span><span class='Modifier2'>○</span><span class='Function'>&lt;</span></code>, and the same relationship holds for <code><span class='Function'>Pair</span></code>.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oMiwz4p+pIOKJjeKXizwgImFiYyIgICMgUGFpciB0d28gdmFsdWVzCuKJjeKXizwgImFiYyIgICAgICAgICMgUGFpciBvbmUoPykgdmFsdWU=">↗️</a><pre> <span class='Bracket'>⟨</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>3</span><span class='Bracket'>⟩</span> <span class='Function'>≍</span><span class='Modifier2'>○</span><span class='Function'>&lt;</span> <span class='String'>&quot;abc&quot;</span> <span class='Comment'># Pair two values
</span>⟨ ⟨ 2 3 ⟩ "abc" ⟩