aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/doc/index.html2
-rw-r--r--docs/doc/join.html52
-rw-r--r--docs/doc/primitive.html2
-rw-r--r--docs/tutorial/list.html2
4 files changed, 52 insertions, 6 deletions
diff --git a/docs/doc/index.html b/docs/doc/index.html
index 2c05a49c..72e9568a 100644
--- a/docs/doc/index.html
+++ b/docs/doc/index.html
@@ -28,7 +28,7 @@
<li><a href="depth.html">Array depth</a> (<code><span class='Function'>≡</span></code> and <code><span class='Modifier2'>⚇</span></code>)</li>
<li><a href="reshape.html">Deshape and Reshape</a> (<code><span class='Function'>⥊</span></code>)</li>
<li><a href="group.html">Group</a> (<code><span class='Function'>⊔</span></code>)</li>
-<li><a href="join.html">Join</a> (<code><span class='Function'>∾</span></code>)</li>
+<li><a href="join.html">Join and Join To</a> (<code><span class='Function'>∾</span></code>)</li>
<li><a href="logic.html">Logical functions</a> (<code><span class='Function'>∧∨¬</span></code>)</li>
<li><a href="prefixes.html">Prefixes and Suffixes</a> (<code><span class='Function'>↑↓</span></code>)</li>
<li><a href="shift.html">Shift functions</a> (<code><span class='Function'>»«</span></code>)</li>
diff --git a/docs/doc/join.html b/docs/doc/join.html
index c324a706..62f478ee 100644
--- a/docs/doc/join.html
+++ b/docs/doc/join.html
@@ -1,11 +1,57 @@
<head>
<link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link href="../style.css" rel="stylesheet"/>
- <title>BQN: Join</title>
+ <title>BQN: Join and Join To</title>
</head>
<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="join">Join</h1>
-<p>Join (<code><span class='Function'>∾</span></code>) is an extension of the monadic function <a href="https://aplwiki.com/wiki/Raze">Raze</a> from A+ and J to arbitrary argument ranks. It has the same relationship to Join to, the dyadic function sharing the same glyph, as <a href="couple.html">Merge</a> (<code><span class='Function'>&gt;</span></code>) does to Couple (<code><span class='Function'>≍</span></code>): <code><span class='Value'>a</span><span class='Function'>≍</span><span class='Value'>b</span></code> is <code><span class='Function'>&gt;</span><span class='Value'>a</span><span class='Ligature'>‿</span><span class='Value'>b</span></code> and <code><span class='Value'>a</span><span class='Function'>∾</span><span class='Value'>b</span></code> is <code><span class='Function'>∾</span><span class='Value'>a</span><span class='Ligature'>‿</span><span class='Value'>b</span></code>. While Merge and Couple combine arrays (the elements of Merge's argument, or the arguments themselves for Couple) along a new leading axis, Join and Join to combine them along the existing leading axis. Both Merge and Join can also be called on a higher-rank array, causing Merge to add multiple leading axes while Join combines elements along multiple existing axes.</p>
+<h1 id="join-and-join-to">Join and Join To</h1>
+<p>The glyph <code><span class='Function'>∾</span></code> combines arrays along an existing axis, a concept that other languages might call &quot;concatenation&quot; or &quot;catenation&quot; but BQN names &quot;Join&quot;. The one-argument form Join and two-argument form Join To are parallel to the <a href="couple.html">functions that combine arrays along a new axis</a>, Merge (<code><span class='Function'>&gt;</span></code>) and Couple (<code><span class='Function'>≍</span></code>).</p>
+<h2 id="join-to">Join To</h2>
+<p>Join To connects its two arguments together, for example to join two strings:</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ImFiY2QiIOKIviAiRUZHIg==">↗️</a><pre> <span class='String'>&quot;abcd&quot;</span> <span class='Function'>∾</span> <span class='String'>&quot;EFG&quot;</span>
+"abcdEFG"
+</pre>
+<p>If the arguments have the same rank, then they are combined along the first axis: the result is an array whose major cells are the major cells of <code><span class='Value'>𝕨</span></code> followed by the major cells of <code><span class='Value'>𝕩</span></code>. For arrays with rank two or more, this means they will be joined &quot;vertically&quot; according to BQN's display.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIGEg4oaQIDMgK+KMnOKXi+KGlSA0CuKKoiBiIOKGkCAy4oC/NCDipYog4oaVOAphIOKIviBi">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>a</span> <span class='Gets'>←</span> <span class='Number'>3</span> <span class='Function'>+</span><span class='Modifier'>⌜</span><span class='Modifier2'>○</span><span class='Function'>↕</span> <span class='Number'>4</span>
+┌─
+╵ 0 1 2 3
+ 1 2 3 4
+ 2 3 4 5
+ ┘
+ <span class='Function'>⊢</span> <span class='Value'>b</span> <span class='Gets'>←</span> <span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>4</span> <span class='Function'>⥊</span> <span class='Function'>↕</span><span class='Number'>8</span>
+┌─
+╵ 0 1 2 3
+ 4 5 6 7
+ ┘
+ <span class='Value'>a</span> <span class='Function'>∾</span> <span class='Value'>b</span>
+┌─
+╵ 0 1 2 3
+ 1 2 3 4
+ 2 3 4 5
+ 0 1 2 3
+ 4 5 6 7
+ ┘
+</pre>
+<p>For this definition to work, major cells of <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code> have to have the same shape. That means that <code><span class='Value'>𝕨</span><span class='Function'>≡</span><span class='Modifier2'>○</span><span class='Paren'>(</span><span class='Number'>1</span><span class='Function'>↓≢</span><span class='Paren'>)</span><span class='Value'>𝕩</span></code>, and the shape of the result is the sum of the lengths of <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code> followed by their shared major cell shape: to use a self-referential definition, the final shape is given by <code><span class='Function'>+</span><span class='Modifier2'>○</span><span class='Function'>≠</span> <span class='Function'>∾</span> <span class='Function'>⊣</span><span class='Modifier'>⁼</span><span class='Modifier2'>○</span><span class='Paren'>(</span><span class='Number'>1</span><span class='Function'>↓≢</span><span class='Paren'>)</span></code> for arguments of equal rank.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=YSDiiL4gMuKAvzXipYpi">↗️</a><pre> <span class='Value'>a</span> <span class='Function'>∾</span> <span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>5</span><span class='Function'>⥊</span><span class='Value'>b</span>
+ERROR
+</pre>
+<p>Join To will also allow arguments with ranks that are one apart. In this case, the smaller-rank argument is treated as a major cell in its entirety. If for example <code><span class='Value'>𝕨</span><span class='Function'>&lt;</span><span class='Modifier2'>○</span><span class='Function'>=</span><span class='Value'>𝕩</span></code>, then we must have <code><span class='Paren'>(</span><span class='Function'>≢</span><span class='Value'>𝕨</span><span class='Paren'>)</span><span class='Function'>≡</span><span class='Number'>1</span><span class='Function'>↓≢</span><span class='Value'>𝕩</span></code>, and the result shape is <code><span class='Number'>1</span><span class='Modifier2'>⊸</span><span class='Function'>+</span><span class='Modifier2'>⌾</span><span class='Function'>⊑≢</span><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=NOKAvzLigL8z4oC/MCDiiL4gYQ==">↗️</a><pre> <span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>0</span> <span class='Function'>∾</span> <span class='Value'>a</span>
+┌─
+╵ 4 2 3 0
+ 0 1 2 3
+ 1 2 3 4
+ 2 3 4 5
+ ┘
+</pre>
+<p>An edge case for Join To is that it can also be applied to two units to make a list:</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MyDiiL4gJ2Mn">↗️</a><pre> <span class='Number'>3</span> <span class='Function'>∾</span> <span class='String'>'c'</span>
+⟨ 3 'c' ⟩
+</pre>
+<p>This case is unusual because the rank of the result is higher than that of either argument. It's also identical to Couple (<code><span class='Function'>≍</span></code>); Couple should be preferred because it doesn't require a special case for this situation. See <a href="couple.html#coupling-units">coupling units</a>.</p>
+<h2 id="join">Join</h2>
+<p>The monadic form of <code><span class='Function'>∾</span></code>, called simply Join, is more complicated than Join To because it really takes not just one argument but an entire array of them. Join is an extension of the monadic function <a href="https://aplwiki.com/wiki/Raze">Raze</a> from A+ and J to arbitrary argument ranks. It has the same relationship to Join to, the dyadic function sharing the same glyph, as <a href="couple.html">Merge</a> (<code><span class='Function'>&gt;</span></code>) does to Couple (<code><span class='Function'>≍</span></code>): <code><span class='Value'>a</span><span class='Function'>≍</span><span class='Value'>b</span></code> is <code><span class='Function'>&gt;</span><span class='Value'>a</span><span class='Ligature'>‿</span><span class='Value'>b</span></code> and <code><span class='Value'>a</span><span class='Function'>∾</span><span class='Value'>b</span></code> is <code><span class='Function'>∾</span><span class='Value'>a</span><span class='Ligature'>‿</span><span class='Value'>b</span></code>. While Merge and Couple combine arrays (the elements of Merge's argument, or the arguments themselves for Couple) along a new leading axis, Join and Join to combine them along the existing leading axis. Both Merge and Join can also be called on a higher-rank array, causing Merge to add multiple leading axes while Join combines elements along multiple existing axes.</p>
<p>Join can be used to combine several strings into a single string, like <code><span class='Value'>array.join</span><span class='Paren'>()</span></code> in Javascript (but it doesn't force the result to be a string).</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oi+InRpbWUi4oC/InRvIuKAvyJqb2luIuKAvyJzb21lIuKAvyJ3b3JkcyI=">↗️</a><pre> <span class='Function'>∾</span><span class='String'>&quot;time&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;to&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;join&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;some&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;words&quot;</span>
"timetojoinsomewords"
diff --git a/docs/doc/primitive.html b/docs/doc/primitive.html
index 755697ec..e943a23c 100644
--- a/docs/doc/primitive.html
+++ b/docs/doc/primitive.html
@@ -135,7 +135,7 @@
<tr>
<td><code><span class='Function'>∾</span></code></td>
<td><a href="join.html">Join</a>*</td>
-<td><a href="https://aplwiki.com/wiki/Catenate">Join to</a></td>
+<td><a href="join.html">Join to</a></td>
</tr>
<tr>
<td><code><span class='Function'>≍</span></code></td>
diff --git a/docs/tutorial/list.html b/docs/tutorial/list.html
index 05e4b9c5..b8d8ffba 100644
--- a/docs/tutorial/list.html
+++ b/docs/tutorial/list.html
@@ -406,7 +406,7 @@ ERROR
<tr>
<td><code><span class='Function'>∾</span></code></td>
<td><a href="../doc/join.html">Join</a></td>
-<td>Join To</td>
+<td><a href="../doc/join.html">Join To</a></td>
</tr>
<tr>
<td><code><span class='Function'>≍</span></code></td>