aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-11 20:08:12 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-06-11 20:08:12 -0400
commitb6bcf214e638fd36ef7d76c9f573a84e6e016482 (patch)
treea435e4f0afed7266b868798e51b792c4600fabe1 /docs
parent383298b70274c5ac22eb2100aad7f6cd8eeca02d (diff)
Nothing but edits yet again
Diffstat (limited to 'docs')
-rw-r--r--docs/doc/assert.html2
-rw-r--r--docs/doc/repeat.html4
-rw-r--r--docs/doc/take.html15
-rw-r--r--docs/doc/train.html22
-rw-r--r--docs/doc/transpose.html32
-rw-r--r--docs/doc/types.html12
6 files changed, 53 insertions, 34 deletions
diff --git a/docs/doc/assert.html b/docs/doc/assert.html
index 83d4b46c..ceccf72a 100644
--- a/docs/doc/assert.html
+++ b/docs/doc/assert.html
@@ -43,7 +43,7 @@
<span class='Number'>0.5</span> <span class='Function'>⌽</span><span class='Modifier2'>⎊</span><span class='Function'>⊣</span> <span class='Function'>↕</span><span class='Number'>6</span> <span class='Comment'># A two-argument example
</span>0.5
</pre>
-<p>Catch doesn't know anything about what an error <em>is</em>, just whether there was one or not. In fact, the idea of error message doesn't feature at all in core BQN: it's purely part of the language environment. So you need a system value to access information about the error. Right now the only one is <code><span class='Function'>•CurrentError</span></code>, which is a function that returns a message for the error currently caught (if any).</p>
+<p>Catch doesn't know anything about what an error <em>is</em>, just whether there was one or not. In fact, the idea of an error message doesn't feature at all in core BQN: it's purely part of the language environment. So you need a system value to access information about the error. Right now the only one is <code><span class='Function'>•CurrentError</span></code>, which is a function that returns a message for the error currently caught (if any).</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oy94o6K4oCiQ3VycmVudEVycm9yIDI=">↗️</a><pre> <span class='Function'>⌽</span><span class='Modifier2'>⎊</span><span class='Function'>•CurrentError</span> <span class='Number'>2</span>
"⌽: Argument cannot be a unit"
</pre>
diff --git a/docs/doc/repeat.html b/docs/doc/repeat.html
index bf097430..62b69b2b 100644
--- a/docs/doc/repeat.html
+++ b/docs/doc/repeat.html
@@ -1,10 +1,10 @@
<head>
<link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/>
<link href="../style.css" rel="stylesheet"/>
- <title>BQN: The Repeat modifier</title>
+ <title>BQN: Repeat</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="the-repeat-modifier"><a class="header" href="#the-repeat-modifier">The Repeat modifier</a></h1>
+<h1 id="repeat"><a class="header" href="#repeat">Repeat</a></h1>
<p>Repeat (<code><span class='Modifier2'>⍟</span></code>) is a 2-modifier that applies its operand function <code><span class='Function'>𝔽</span></code> multiple times.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=wrvCu8K7ICJBQkNERSIKCsK74o2fMyAiQUJDREUi">↗️</a><pre> <span class='Function'>»»»</span> <span class='String'>&quot;ABCDE&quot;</span>
" AB"
diff --git a/docs/doc/take.html b/docs/doc/take.html
index 1dd895ff..1c976976 100644
--- a/docs/doc/take.html
+++ b/docs/doc/take.html
@@ -38,15 +38,16 @@
<li><code><span class='Value'>𝕩</span></code> can be an atom, or array of any rank (the result will be an array).</li>
<li><code><span class='Value'>𝕨</span></code> can be negative to take or drop from the end instead of the beginning.</li>
<li>For Take, if <code><span class='Value'>𝕨</span></code> is larger than the length of <code><span class='Value'>𝕩</span></code>, then <a href="fill.html">fills</a> are added.</li>
-<li><code><span class='Value'>𝕨</span></code> can have multiple numbers corresponding to leading axes of <code><span class='Value'>𝕩</span></code>.</li>
+<li><code><span class='Value'>𝕨</span></code> can have multiple numbers corresponding to <a href="leading.html">leading</a> axes of <code><span class='Value'>𝕩</span></code>.</li>
<li><code><span class='Value'>𝕨</span></code> is allowed to be longer than the rank of <code><span class='Value'>𝕩</span></code>; <code><span class='Value'>𝕩</span></code> will be extended to fit.</li>
</ul>
-<p>These extensions can be combined as well, so there are a lot of possibilities. A good picture to have in mind is cutting out a corner of the array <code><span class='Value'>𝕩</span></code>. This is because the result <code><span class='Value'>𝕨</span><span class='Function'>↑</span><span class='Value'>𝕩</span></code> or <code><span class='Value'>𝕨</span><span class='Function'>↓</span><span class='Value'>𝕩</span></code> always aligns with one side of <code><span class='Value'>𝕩</span></code> along each axis, so it aligns with the corner where those sides meet.</p>
+<p>These extensions can be combined as well, so there are a lot of possibilities. A good picture to have in mind is cutting out a corner of the array <code><span class='Value'>𝕩</span></code>. This is because the result <code><span class='Value'>𝕨</span><span class='Function'>↑</span><span class='Value'>𝕩</span></code> or <code><span class='Value'>𝕨</span><span class='Function'>↓</span><span class='Value'>𝕩</span></code> always aligns with one side of <code><span class='Value'>𝕩</span></code> along each axis, so it also aligns with the corner where those sides meet.</p>
<p>The result <code><span class='Value'>d</span><span class='Function'>↓</span><span class='Value'>𝕩</span></code> is always the same as <code><span class='Value'>t</span><span class='Function'>↑</span><span class='Value'>𝕩</span></code> for some other argument <code><span class='Value'>t</span></code>, but computing <code><span class='Value'>t</span></code> wouldn't be too convenient. The reverse isn't true: only Take can insert fills, so results that include them can't come from Drop.</p>
<h2 id="one-axis"><a class="header" href="#one-axis">One axis</a></h2>
-<p>Let's start with a natural number <code><span class='Value'>𝕨</span></code>. Take gives the first <code><span class='Value'>𝕨</span></code> major cells of <code><span class='Value'>𝕩</span></code> (or elements of a list), while Drop gives all but the first <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=NCDihpEgInRha2UgYW5kIGRyb3AiCjQg4oaTICJ0YWtlIGFuZCBkcm9wIgoKMSDihpMgPiJtYWoi4oC/Im9yYyLigL8iZWxsIg==">↗️</a><pre> <span class='Number'>4</span> <span class='Function'>↑</span> <span class='String'>&quot;take and drop&quot;</span>
+<p>Let's start with a natural number <code><span class='Value'>𝕨</span></code>. Take gives the first <code><span class='Value'>𝕨</span></code> <a href="array.html#cells">major cells</a> of <code><span class='Value'>𝕩</span></code> (or elements of a list), while Drop gives all but the first <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=NCDihpEgInRha2UgYW5kIGRyb3AiCgo0IOKGkyAidGFrZSBhbmQgZHJvcCIKCjEg4oaTID4ibWFqIuKAvyJvcmMi4oC/ImVsbCI=">↗️</a><pre> <span class='Number'>4</span> <span class='Function'>↑</span> <span class='String'>&quot;take and drop&quot;</span>
"take"
+
<span class='Number'>4</span> <span class='Function'>↓</span> <span class='String'>&quot;take and drop&quot;</span>
" and drop"
@@ -77,7 +78,7 @@
⟨⟩
</pre>
<h3 id="negative-argument"><a class="header" href="#negative-argument">Negative argument</a></h3>
-<p>If <code><span class='Value'>𝕨</span></code> is negative then wraps around the other side to take or drop from the end of <code><span class='Value'>𝕩</span></code>. It's a lot like negative indices in <a href="select.html">Select</a> (<code><span class='Function'>⊏</span></code>), but while negative indices are asymmetric—<code><span class='Number'>0</span></code> is the first entry but <code><span class='Number'>¯1</span></code> is the last—this case is symmetric. It's because the place to cut is always <em>before</em> the index <code><span class='Value'>𝕨</span></code>, cancelling out the negative index asymmetry.</p>
+<p>If <code><span class='Value'>𝕨</span></code> is negative, it wraps around the other side to take or drop from the end of <code><span class='Value'>𝕩</span></code>. It's a lot like negative indices in <a href="select.html">Select</a> (<code><span class='Function'>⊏</span></code>), but while negative indices are asymmetric—<code><span class='Number'>0</span></code> is the first entry but <code><span class='Number'>¯1</span></code> is the last—this case is symmetric. It's because the place to cut is always <em>before</em> the index <code><span class='Value'>𝕨</span></code>, cancelling out the negative index asymmetry.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MyDihpEgImFiY2RlRURDQkEiCgrCrzMg4oaRICJhYmNkZUVEQ0JBIiAgIyBMYXN0IHRocmVlCgrCrzMg4oaTICJhYmNkZUVEQ0JBIiAgIyBBbGwgYnV0IHRoZSBsYXN0IHRocmVl">↗️</a><pre> <span class='Number'>3</span> <span class='Function'>↑</span> <span class='String'>&quot;abcdeEDCBA&quot;</span>
"abc"
@@ -94,12 +95,12 @@
<span class='Number'>0</span> <span class='Function'>↓</span> <span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>2</span> <span class='Comment'># Everything
</span>⟨ 4 3 2 ⟩
</pre>
-<p>If <code><span class='Function'>|</span><span class='Value'>𝕨</span></code> is too large, then Take will insert fills at the beginning to keep the result aligned with <code><span class='Value'>𝕩</span></code> at the end. Drop returns an empty array as in the positive case. So unlike <a href="reverse.html">Rotate</a> (<code><span class='Function'>⌽</span></code>), which is completely cyclical, Take and Drop work cyclically only around 0.</p>
+<p>If <code><span class='Function'>|</span><span class='Value'>𝕨</span></code> is too large, then Take will insert fills at the beginning to keep the result aligned with <code><span class='Value'>𝕩</span></code> at the end. Drop returns an empty array as in the positive case. So unlike <a href="reverse.html">Rotate</a> (<code><span class='Function'>⌽</span></code>), which is completely cyclical, Take and Drop look cyclic only around 0.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=wq82IOKGkSAieHki">↗️</a><pre> <span class='Number'>¯6</span> <span class='Function'>↑</span> <span class='String'>&quot;xy&quot;</span>
" xy"
</pre>
<h2 id="multiple-axes"><a class="header" href="#multiple-axes">Multiple axes</a></h2>
-<p>In the general case <code><span class='Value'>𝕨</span></code> is a list of integers. They're matched with the leading axes of <code><span class='Value'>𝕩</span></code>, so that each affects one axis independently from the others.</p>
+<p>In the general case <code><span class='Value'>𝕨</span></code> is a list of integers. They're matched with the <a href="leading.html">leading axes</a> of <code><span class='Value'>𝕩</span></code>, so that each affects one axis independently from the others.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIG0g4oaQICgxMMOX4oaVNSkgK+KMnCDihpU3CgrCrzTigL8yIOKGkSBtICAjIExhc3QgZm91ciByb3dzOyBmaXJzdCB0d28gY29sdW1ucwoKwq804oC/MiDihpMgbQ==">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>m</span> <span class='Gets'>←</span> <span class='Paren'>(</span><span class='Number'>10</span><span class='Function'>×↕</span><span class='Number'>5</span><span class='Paren'>)</span> <span class='Function'>+</span><span class='Modifier'>⌜</span> <span class='Function'>↕</span><span class='Number'>7</span>
┌─
╵ 0 1 2 3 4 5 6
diff --git a/docs/doc/train.html b/docs/doc/train.html
index d45742b0..61e253ea 100644
--- a/docs/doc/train.html
+++ b/docs/doc/train.html
@@ -5,7 +5,7 @@
</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="function-trains"><a class="header" href="#function-trains">Function trains</a></h1>
-<p>Trains are an important aspect of BQN's <a href="tacit.html">tacit</a> programming capabilities. In fact, a crucial one: with trains and the <a href="identity.html">identity functions</a> Left (<code><span class='Function'>⊣</span></code>) and Right (<code><span class='Function'>⊢</span></code>), a fully tacit program can express any explicit function whose body is a statement with <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code> used only as arguments (that is, there are no assignments and <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code> are not used in operands or lists. Functions with assignments may have too many variables active at once to be directly translated but can be emulated by constructing lists. But it's probably a bad idea). Without trains it isn't possible to have two different functions that each use both arguments to a dyadic function. With trains it's perfectly natural.</p>
+<p>Trains are an important aspect of BQN's <a href="tacit.html">tacit</a> programming capabilities. In fact, a crucial one: with trains, the <a href="identity.html">identity functions</a> Left (<code><span class='Function'>⊣</span></code>) and Right (<code><span class='Function'>⊢</span></code>), and <a href="constant.html">Constant</a> (<code><span class='Modifier'>˙</span></code>), a fully tacit program can express any explicit function whose body is a statement with <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code> used only as arguments (that is, there are no assignments and <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code> are not used in operands or lists. Functions with assignments may have too many variables active at once to be directly translated but can be emulated by constructing lists. But it's probably a bad idea). Without trains it isn't possible to have two different functions that each use both arguments to a dyadic function. With trains it's perfectly natural.</p>
<p>BQN's trains are the same as those of Dyalog APL, except that Dyalog is missing the minor convenience of BQN's <a href="expression.html#nothing">Nothing</a> (<code><span class='Nothing'>·</span></code>). There are many Dyalog-based documents and videos on trains you can view on the <a href="https://aplwiki.com/wiki/Train">APL Wiki</a>.</p>
<h2 id="2-train-3-train"><a class="header" href="#2-train-3-train">2-train, 3-train</a></h2>
<p>Trains are an adaptation of the mathematical convention that, for example, two functions <code><span class='Function'>F</span></code> and <code><span class='Function'>G</span></code> can be added to get a new function <code><span class='Function'>F+G</span></code> that applies as <code><span class='Paren'>(</span><span class='Function'>F+G</span><span class='Paren'>)(</span><span class='Value'>x</span><span class='Paren'>)</span> <span class='Function'>=</span> <span class='Function'>F</span><span class='Paren'>(</span><span class='Value'>x</span><span class='Paren'>)</span><span class='Function'>+G</span><span class='Paren'>(</span><span class='Value'>x</span><span class='Paren'>)</span></code>. With a little change to the syntax, we can do exactly this in BQN:</p>
@@ -13,10 +13,10 @@
⟨ 4 4 4 4 4 ⟩
</pre>
<p>So given a list of the first few natural numbers, that <em>same</em> list <em>plus</em> its <em>reverse</em> gives a list of just one number repeated many times. I'm sure if I were <a href="https://en.wikipedia.org/wiki/Carl_Friedrich_Gauss#Anecdotes">Gauss</a> I'd be able to find some clever use for that fact. The mathematical convention extends to any central operator and any number of function arguments, which in BQN means we use any three functions, and call the train with a left argument as well—the only numbers of arguments BQN syntax allows are 1 and 2.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=NyAoK+KJjS0pIDI=">↗️</a><pre> <span class='Number'>7</span> <span class='Paren'>(</span><span class='Function'>+≍-</span><span class='Paren'>)</span> <span class='Number'>2</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=NyAoK+KLiC0pIDI=">↗️</a><pre> <span class='Number'>7</span> <span class='Paren'>(</span><span class='Function'>+⋈-</span><span class='Paren'>)</span> <span class='Number'>2</span>
⟨ 9 5 ⟩
</pre>
-<p>Here <a href="couple.html">Couple</a> (<code><span class='Function'>≍</span></code>) is used to combine two units into a list, so we get seven plus and minus two. It's also possible to leave out the leftmost function of a train, or replace it with <code><span class='Nothing'>·</span></code>. In this case the function on the right is called, then the other function is called on its result—it's identical to the mathematical composition <code><span class='Modifier2'>∘</span></code>, which is also part of BQN.</p>
+<p><a href="pair.html">Pair</a> (<code><span class='Function'>⋈</span></code>) makes a list from two values, so we get seven plus and minus two. It's also possible to leave out the leftmost function of a train, or replace it with <code><span class='Nothing'>·</span></code>. In this case the function on the right is called, then the other function is called on its result—it's identical to the mathematical <a href="compose.html">composition</a> <code><span class='Modifier2'>∘</span></code>, which is also part of BQN.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KOKIvuKMvSkgImFiIuKAvyJjZGUi4oC/ImYiCijCt+KIvuKMvSkgImFiIuKAvyJjZGUi4oC/ImYiCuKIvuKImOKMvSAiYWIi4oC/ImNkZSLigL8iZiI=">↗️</a><pre> <span class='Paren'>(</span><span class='Function'>∾⌽</span><span class='Paren'>)</span> <span class='String'>&quot;ab&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;cde&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;f&quot;</span>
"fcdeab"
<span class='Paren'>(</span><span class='Nothing'>·</span><span class='Function'>∾⌽</span><span class='Paren'>)</span> <span class='String'>&quot;ab&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;cde&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;f&quot;</span>
@@ -26,20 +26,20 @@
</pre>
<p>The three functions <code><span class='Function'>∾⌽</span></code>, <code><span class='Nothing'>·</span><span class='Function'>∾⌽</span></code>, and <code><span class='Function'>∾</span><span class='Modifier2'>∘</span><span class='Function'>⌽</span></code> are completely identical: <a href="join.html#join">Join</a> of <a href="reverse.html">Reverse</a>. Why might we want <strong>three</strong> different ways to write the same thing? If we only want to define a function, there's hardly any difference. However, these three forms have different syntax, and might be easier or harder to use in different contexts. As we'll see, we can use <code><span class='Function'>∾</span><span class='Modifier2'>∘</span><span class='Function'>⌽</span></code> inside a train without parenthesizing it, and string <code><span class='Nothing'>·</span><span class='Function'>∾⌽</span></code> but not <code><span class='Function'>∾⌽</span></code> together with other trains. Let's look at how the train syntax extends to longer expressions.</p>
<h2 id="longer-trains"><a class="header" href="#longer-trains">Longer trains</a></h2>
-<p>Function application in trains, as in other contexts, shares the lowest precedence level with assignment. Modifiers and strands (with <code><span class='Ligature'>‿</span></code>) have higher precedence, so they are applied before forming any trains. Once this is done, an expression is a <em>subject expression</em> if it ends with a subject and a <em>function expression</em> if it ends with a function (there are also modifier expressions, which aren't relevant here). A train is any function expression with multiple functions or subjects in it: while we've seen examples with two or three functions, any number are allowed.</p>
-<p>Subject expressions are the domain of &quot;old-school&quot; APL, and just apply one function after another to a subject, possibly assigning some of the results (that's the top-level picture—anything can still happen within parentheses). Subjects other than the first appear only as left arguments to functions, which means that two subjects can't appear next to each other because the one on the left would have no corresponding function. Here's an example from the compiler (at one point), with functions and assignments numbered in the order they are applied and their arguments marked with <code><span class='Function'>«»</span></code>, and a fully-parenthesized version shown below.</p>
+<p>Function application in trains, as in other contexts, shares the lowest precedence level with assignment. Modifiers and strands (with <code><span class='Ligature'>‿</span></code>) have higher precedence, so they are applied before forming any trains. Once this is done, an expression is a <em>subject expression</em> if it ends with a subject and a <em>function expression</em> if it ends with a function (a lone modifier can also be an expression, which isn't either of these). A train is any function expression with multiple functions or subjects in it: while we've seen examples with two or three functions, any number are allowed.</p>
+<p>Subject expressions are the domain of &quot;old-school&quot; APL, and just apply one function after another to a subject, possibly assigning some of the results (that's the top-level picture—anything can still happen within parentheses). Subjects other than the first appear only as left arguments to functions, which means that two subjects can't appear next to each other because the one on the left would have no corresponding function. Here's an example from BQN's compiler, with functions and assignments numbered in the order they are applied and their arguments marked with <code><span class='Function'>«»</span></code>, and a fully-parenthesized version shown below.</p>
<pre><span class='Value'>cn</span><span class='Gets'>←</span><span class='Value'>pi</span><span class='Function'>∾</span><span class='Value'>lt</span><span class='Gets'>←</span><span class='Function'>/</span><span class='Value'>𝕩</span><span class='Function'>≥</span><span class='Value'>ci</span><span class='Gets'>←</span><span class='Value'>vi</span><span class='Function'>+</span><span class='Value'>nv</span>
<span class='Function'>«</span><span class='Number'>6</span> <span class='Function'>«</span><span class='Number'>5</span> <span class='Function'>«</span><span class='Number'>43</span><span class='Function'>«</span><span class='Number'>2</span> <span class='Function'>«</span><span class='Number'>1</span> <span class='Function'>«</span><span class='Number'>0</span><span class='Function'>»</span>
<span class='Value'>cn</span><span class='Gets'>←</span><span class='Paren'>(</span><span class='Value'>pi</span><span class='Function'>∾</span><span class='Paren'>(</span><span class='Value'>lt</span><span class='Gets'>←</span><span class='Paren'>(</span><span class='Function'>/</span><span class='Paren'>(</span><span class='Value'>𝕩</span><span class='Function'>≥</span><span class='Paren'>(</span><span class='Value'>ci</span><span class='Gets'>←</span><span class='Paren'>(</span><span class='Value'>vi</span><span class='Function'>+</span><span class='Value'>nv</span><span class='Paren'>))))))</span>
</pre>
-<p>Function expressions have related but different rules, driven by the central principle that functions can be used as &quot;arguments&quot;. Because roles can no longer be used to distinguish functions from their arguments, every function is assumed to have two arguments unless there's nothing to the left of it, or an assignment. In trains, assignments can't appear in the middle, only at the left side after all the functions have been applied. Here's another example from the compiler. Remember that for our purposes <code><span class='Function'>⌈</span><span class='Modifier'>`</span></code> behaves as a single component.</p>
+<p>Function expressions have related but different rules, driven by the central principle that functions can be used as &quot;arguments&quot;. Because roles can no longer be used to distinguish functions from their arguments, every function is assumed to have two arguments unless there's nothing to the left of it, or an assignment. In trains, assignments can't appear in the middle, only at the left side apart from all the functions. Here's another example from the compiler. Remember that for our purposes <code><span class='Function'>⌈</span><span class='Modifier'>`</span></code> behaves as a single component.</p>
<pre><span class='Function'>⊢&gt;</span><span class='Number'>¯1</span><span class='Function'>»⌈</span><span class='Modifier'>`</span>
<span class='Function'>«</span><span class='Number'>1</span> <span class='Function'>«</span><span class='Number'>0</span><span class='Function'>»</span>
<span class='Function'>⊢&gt;</span><span class='Paren'>(</span><span class='Number'>¯1</span><span class='Function'>»⌈</span><span class='Modifier'>`</span><span class='Paren'>)</span>
</pre>
-<p>In a train, arguments alternate strictly with combining functions between them. Arguments can be either functions or subjects, except for the rightmost one, which has to be a function to indicate that the expression is a train. Trains tend to be shorter than subject expressions partly because to keep track of this alternation in a train of all functions, you need to know where each function is relative to the end of the train (subjects like the <code><span class='Number'>¯1</span></code> above only occur as left arguments, so they can also serve as anchors).</p>
+<p>In a train, arguments alternate strictly with combining functions between them. Arguments can be either functions or subjects, except for the rightmost one, which has to be a function to indicate that the expression is a train. Trains tend to be shorter than subject expressions partly because this rule leads to some difficulty when reading. To keep track of the alternation in a train of all functions, you need to know where each function is relative to the end of the train (subjects like the <code><span class='Number'>¯1</span></code> above only occur as left arguments, so they can also serve as anchors).</p>
<h2 id="practice-training"><a class="header" href="#practice-training">Practice training</a></h2>
<p>The train <code><span class='Function'>⊢&gt;</span><span class='Number'>¯1</span><span class='Function'>»⌈</span><span class='Modifier'>`</span></code> is actually a nice trick to get the result of <a href="selfcmp.html#mark-firsts">Mark Firsts</a> <code><span class='Function'>∊</span><span class='Value'>𝕩</span></code> given the result of <a href="selfcmp.html#classify">Classify</a> <code><span class='Function'>⊐</span><span class='Value'>𝕩</span></code>, without doing another search. Let's take a closer look, first by applying it mechanically. To do this, we apply each &quot;argument&quot; to the train's argument, and then combine them with the combining functions.</p>
<pre><span class='Paren'>(</span><span class='Function'>⊢</span> <span class='Function'>&gt;</span> <span class='Number'>¯1</span> <span class='Function'>»</span> <span class='Function'>⌈</span><span class='Modifier'>`</span><span class='Paren'>)</span> <span class='Value'>𝕩</span>
@@ -47,7 +47,7 @@
<span class='Value'>𝕩</span> <span class='Function'>&gt;</span> <span class='Number'>¯1</span> <span class='Function'>»</span> <span class='Function'>⌈</span><span class='Modifier'>`</span><span class='Value'>𝕩</span>
</pre>
<p>So—although not all trains simplify so much—this confusing train is just <code><span class='Brace'>{</span><span class='Value'>𝕩</span><span class='Function'>&gt;</span><span class='Number'>¯1</span><span class='Function'>»⌈</span><span class='Modifier'>`</span><span class='Value'>𝕩</span><span class='Brace'>}</span></code>! Why would I write it in such an obtuse way? To someone used to working with trains, the function <code><span class='Paren'>(</span><span class='Function'>⊢&gt;</span><span class='Number'>¯1</span><span class='Function'>»⌈</span><span class='Modifier'>`</span><span class='Paren'>)</span></code> isn't any more complicated to read: <code><span class='Function'>⊢</span></code> in an argument position of a train just means <code><span class='Value'>𝕩</span></code> while <code><span class='Function'>⌈</span><span class='Modifier'>`</span></code> will be applied to the arguments. Using the train just means slightly shorter code and two fewer <code><span class='Value'>𝕩</span></code>s to trip over.</p>
-<p>This function's argument is Classify (<code><span class='Function'>⊐</span></code>) of some list (in fact this technique also works on the <a href="search.html#index-of">index-of</a>-self <code><span class='Value'>𝕩</span><span class='Function'>⊐</span><span class='Value'>𝕩</span></code>). Classify moves along its argument, giving each major cell a number: the first unused natural number if that value hasn't been seen yet, and otherwise the number chosen when it was first seen. It can be implemented as <code><span class='Function'>⍷⊐⊢</span></code>, another train!</p>
+<p>This function's argument is Classify (<code><span class='Function'>⊐</span></code>) of some list (in fact this technique also works on the <a href="search.html#index-of">index-of</a>-self <code><span class='Value'>𝕩</span><span class='Function'>⊐</span><span class='Value'>𝕩</span></code>). Classify moves along its argument, giving each major cell a number: the first unused natural number if that value hasn't been seen yet, and otherwise the number chosen when it was first seen. It can in turn be implemented as <code><span class='Function'>⍷⊐⊢</span></code>, another train!</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIHNjIOKGkCDiipAgInRhY2l0dHJhaW5zIg==">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>sc</span> <span class='Gets'>←</span> <span class='Function'>⊐</span> <span class='String'>&quot;tacittrains&quot;</span>
⟨ 0 1 2 3 0 0 4 1 3 5 6 ⟩
</pre>
@@ -76,19 +76,19 @@
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4o234oinfCAz4oC/NOKAv8KvM+KAv8KvMuKAvzA=">↗️</a><pre> <span class='Function'>⍷∧|</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>¯3</span><span class='Ligature'>‿</span><span class='Number'>¯2</span><span class='Ligature'>‿</span><span class='Number'>0</span>
⟨ 0 2 3 4 ⟩
</pre>
-<p>If it doesn't have to be a function, it's easiest to write it all out! Let's assume we want a tacit function instead. With three one-argument functions, we can't use a 3-train, as the middle function in a 3-train always has two arguments. Instead, we will compose the functions with 2-trains. Composition is associative, meaning that this can be done starting at either the left or the right.</p>
+<p>If it doesn't have to be a function, that's easiest to write it out! Let's assume we want a tacit function instead. With three one-argument functions, we can't use a 3-train, as the middle function in a 3-train always has two arguments. Instead, we will compose the functions with 2-trains. Composition is associative, meaning that this can be done starting at either the left or the right.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KCjijbfiiKcpfCkgM+KAvzTigL/CrzPigL/CrzLigL8wCijijbco4oinfCkpIDPigL804oC/wq8z4oC/wq8y4oC/MA==">↗️</a><pre> <span class='Paren'>((</span><span class='Function'>⍷∧</span><span class='Paren'>)</span><span class='Function'>|</span><span class='Paren'>)</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>¯3</span><span class='Ligature'>‿</span><span class='Number'>¯2</span><span class='Ligature'>‿</span><span class='Number'>0</span>
⟨ 0 2 3 4 ⟩
<span class='Paren'>(</span><span class='Function'>⍷</span><span class='Paren'>(</span><span class='Function'>∧|</span><span class='Paren'>))</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>¯3</span><span class='Ligature'>‿</span><span class='Number'>¯2</span><span class='Ligature'>‿</span><span class='Number'>0</span>
⟨ 0 2 3 4 ⟩
</pre>
-<p>We might make the first train above easier to read by using Atop (<code><span class='Modifier2'>∘</span></code>) instead of a 2-train. Atop is a 2-modifier, so it doesn't need parentheses when used in a train. The second train can also be changed to <code><span class='Function'>⍷∧</span><span class='Modifier2'>∘</span><span class='Function'>|</span></code> in the same way, but there is another option: the rightmost train <code><span class='Function'>∧|</span></code> can be expanded to <code><span class='Nothing'>·</span><span class='Function'>∧|</span></code>. After this it's an odd-length train in the last position, and doesn't need parentheses anymore.</p>
+<p>We might make the first train above easier to read by using <a href="compose.html#atop">Atop</a> (<code><span class='Modifier2'>∘</span></code>) instead of a 2-train. Atop is a 2-modifier, so it doesn't need parentheses when used in a train. The second train can also be changed to <code><span class='Function'>⍷∧</span><span class='Modifier2'>∘</span><span class='Function'>|</span></code> in the same way, but there is another option: the rightmost train <code><span class='Function'>∧|</span></code> can be expanded to <code><span class='Nothing'>·</span><span class='Function'>∧|</span></code>. After this it's an odd-length train in the last position, and doesn't need parentheses anymore.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KOKNt+KImOKIp3wpIDPigL804oC/wq8z4oC/wq8y4oC/MAoo4o23wrfiiKd8KSAz4oC/NOKAv8KvM+KAv8KvMuKAvzA=">↗️</a><pre> <span class='Paren'>(</span><span class='Function'>⍷</span><span class='Modifier2'>∘</span><span class='Function'>∧|</span><span class='Paren'>)</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>¯3</span><span class='Ligature'>‿</span><span class='Number'>¯2</span><span class='Ligature'>‿</span><span class='Number'>0</span>
⟨ 0 2 3 4 ⟩
<span class='Paren'>(</span><span class='Function'>⍷</span><span class='Nothing'>·</span><span class='Function'>∧|</span><span class='Paren'>)</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>¯3</span><span class='Ligature'>‿</span><span class='Number'>¯2</span><span class='Ligature'>‿</span><span class='Number'>0</span>
⟨ 0 2 3 4 ⟩
</pre>
-<p>These two forms have a different emphasis, because the first breaks into subfunctions <code><span class='Function'>⍷</span><span class='Modifier2'>∘</span><span class='Function'>∧</span></code> and <code><span class='Function'>|</span></code> and the second into <code><span class='Function'>⍷</span></code> and <code><span class='Function'>∧|</span></code>. It's more common to use <code><span class='Function'>⍷</span><span class='Modifier2'>∘</span><span class='Function'>∧</span></code> as a unit than <code><span class='Function'>∧|</span></code>, so in this case <code><span class='Function'>⍷</span><span class='Modifier2'>∘</span><span class='Function'>∧|</span></code> is probably the better train.</p>
+<p>These two forms have a different emphasis, because the first breaks into subfunctions <code><span class='Function'>⍷</span><span class='Modifier2'>∘</span><span class='Function'>∧</span></code> and <code><span class='Function'>|</span></code> and the second into <code><span class='Function'>⍷</span></code> and <code><span class='Function'>∧|</span></code>. It's more common to use <code><span class='Function'>⍷</span><span class='Modifier2'>∘</span><span class='Function'>∧</span></code> together than <code><span class='Function'>∧|</span></code>, so in this case <code><span class='Function'>⍷</span><span class='Modifier2'>∘</span><span class='Function'>∧|</span></code> is probably the better train.</p>
<p>Many one-argument functions strung together is <a href="../commentary/problems.html#trains-dont-like-monads">a major weakness</a> for train syntax. If there are many such functions it's probably best to stick with a block function instead!</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=e+KNt+KIp3zwnZWpfSAz4oC/NOKAv8KvM+KAv8KvMuKAvzA=">↗️</a><pre> <span class='Brace'>{</span><span class='Function'>⍷∧|</span><span class='Value'>𝕩</span><span class='Brace'>}</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>¯3</span><span class='Ligature'>‿</span><span class='Number'>¯2</span><span class='Ligature'>‿</span><span class='Number'>0</span>
⟨ 0 2 3 4 ⟩
diff --git a/docs/doc/transpose.html b/docs/doc/transpose.html
index 807173ba..8c9841b3 100644
--- a/docs/doc/transpose.html
+++ b/docs/doc/transpose.html
@@ -36,7 +36,7 @@
<span class='Function'>≢</span> <span class='Function'>⍉</span> <span class='Value'>a23456</span>
⟨ 3 4 5 6 2 ⟩
</pre>
-<p>In terms of the argument data as given by <a href="reshape.html#deshape">Deshape</a> (<code><span class='Function'>⥊</span></code>), this looks like a simple 2-dimensional transpose: one axis is exchanged with a compound axis made up of the other axes. Here we transpose a rank 3 matrix:</p>
+<p>In terms of the index-ordered elements as given by <a href="reshape.html#deshape">Deshape</a> (<code><span class='Function'>⥊</span></code>), this looks like a simple 2-dimensional transpose: one axis is exchanged with a compound axis made up of the other axes. Here we transpose a rank 3 matrix:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=YTMyMiDihpAgM+KAvzLigL8y4qWK4oaVMTIK4ouI4p+c4o2JIGEzMjI=">↗️</a><pre> <span class='Value'>a322</span> <span class='Gets'>←</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Function'>⥊↕</span><span class='Number'>12</span>
<span class='Function'>⋈</span><span class='Modifier2'>⟜</span><span class='Function'>⍉</span> <span class='Value'>a322</span>
┌─
@@ -71,7 +71,7 @@
⟨ 6 2 3 4 5 ⟩
</pre>
<p>In fact, we have <code><span class='Function'>≢⍉</span><span class='Modifier2'>⍟</span><span class='Value'>k</span> <span class='Value'>a</span> <span class='Gets'>←→</span> <span class='Value'>k</span><span class='Function'>⌽≢</span><span class='Value'>a</span></code> for any whole number <code><span class='Value'>k</span></code> and array <code><span class='Value'>a</span></code>.</p>
-<p>To move axes other than the first, use the Rank modifier in order to leave initial axes untouched. A rank of <code><span class='Value'>k</span><span class='Function'>&gt;</span><span class='Number'>0</span></code> transposes only the last <code><span class='Value'>k</span></code> axes while a rank of <code><span class='Value'>k</span><span class='Function'>&lt;</span><span class='Number'>0</span></code> ignores the first <code><span class='Function'>|</span><span class='Value'>k</span></code> axes.</p>
+<p>To move axes other than the first, use the <a href="rank.html">Rank modifier</a> in order to leave initial axes untouched. A rank of <code><span class='Value'>k</span><span class='Function'>&gt;</span><span class='Number'>0</span></code> transposes only the last <code><span class='Value'>k</span></code> axes while a rank of <code><span class='Value'>k</span><span class='Function'>&lt;</span><span class='Number'>0</span></code> ignores the first <code><span class='Function'>|</span><span class='Value'>k</span></code> axes.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omiIOKNieKOiTMgYTIzNDU2">↗️</a><pre> <span class='Function'>≢</span> <span class='Function'>⍉</span><span class='Modifier2'>⎉</span><span class='Number'>3</span> <span class='Value'>a23456</span>
⟨ 2 3 5 6 4 ⟩
</pre>
@@ -82,14 +82,14 @@
<p>Using these forms (and the <a href="shape.html">Rank</a> function), we can state BQN's generalized matrix product swapping rule:</p>
<pre><span class='Value'>a</span> <span class='Function'>MP</span> <span class='Value'>b</span> <span class='Gets'>←→</span> <span class='Function'>⍉</span><span class='Modifier2'>⍟</span><span class='Paren'>(</span><span class='Number'>1</span><span class='Function'>-=</span><span class='Value'>a</span><span class='Paren'>)</span> <span class='Paren'>(</span><span class='Function'>⍉</span><span class='Value'>b</span><span class='Paren'>)</span> <span class='Function'>MP</span> <span class='Paren'>(</span><span class='Function'>⍉</span><span class='Modifier'>⁼</span><span class='Value'>a</span><span class='Paren'>)</span>
</pre>
-<p>Certainly not as concise as APL's version, but not a horror either. BQN's rule is actually more parsimonious in that it only performs the axis exchanges necessary for the computation: it moves the two axes that will be paired with the matrix product into place before the product, and directly exchanges all axes afterwards. Each of these steps is equivalent in terms of data movement to a matrix transpose, the simplest nontrivial transpose to perform. Also remember that for two-dimensional matrices both kinds of transposition are the same, so that APL's simpler rule <code><span class='Function'>MP</span> <span class='Function'>≡</span> <span class='Function'>MP</span><span class='Modifier2'>⌾</span><span class='Function'>⍉</span><span class='Modifier'>˜</span></code> holds in BQN.</p>
+<p>Certainly not as concise as APL's version, but not a horror either. BQN's rule is actually more parsimonious in that it only performs the axis exchanges necessary for the computation: it moves the two axes that will be paired with the matrix product into place before the product, and directly exchanges all axes afterwards. Each of these steps is equivalent in terms of data movement to a matrix transpose, the simplest nontrivial transpose to perform. Also remember that for two-dimensional matrices both kinds of transposition are the same, so that APL's simpler rule <code><span class='Function'>MP</span> <span class='Function'>≡</span> <span class='Function'>MP</span><span class='Modifier2'>⌾</span><span class='Function'>⍉</span><span class='Modifier'>˜</span></code> holds in BQN on rank 2.</p>
<p>Axis permutations of the types we've shown generate the complete permutation group on any number of axes, so you could produce any transposition you want with the right sequence of monadic transpositions with Rank. However, this can be unintuitive and tedious. What if you want to transpose the first three axes, leaving the rest alone? With monadic Transpose you have to send some axes to the end, then bring them back to the beginning. For example [following four or five failed tries]:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omiIOKNieKBvOKOicKvMiDijYkgYTIzNDU2ICAjIFJlc3RyaWN0IFRyYW5zcG9zZSB0byB0aGUgZmlyc3QgdGhyZWUgYXhlcw==">↗️</a><pre> <span class='Function'>≢</span> <span class='Function'>⍉</span><span class='Modifier'>⁼</span><span class='Modifier2'>⎉</span><span class='Number'>¯2</span> <span class='Function'>⍉</span> <span class='Value'>a23456</span> <span class='Comment'># Restrict Transpose to the first three axes
</span>⟨ 3 4 2 5 6 ⟩
</pre>
<p>In a case like this the dyadic version of <code><span class='Function'>⍉</span></code>, called Reorder Axes, is much easier.</p>
<h2 id="reorder-axes"><a class="header" href="#reorder-axes">Reorder Axes</a></h2>
-<p>Transpose also allows a left argument that specifies a permutation of <code><span class='Value'>𝕩</span></code>'s axes. For each index <code><span class='Value'>p</span><span class='Gets'>←</span><span class='Value'>i</span><span class='Function'>⊑</span><span class='Value'>𝕨</span></code> in the left argument, axis <code><span class='Value'>i</span></code> of <code><span class='Value'>𝕩</span></code> is used for axis <code><span class='Value'>p</span></code> of the result. Multiple argument axes can be sent to the same result axis, in which case that axis goes along a diagonal of <code><span class='Value'>𝕩</span></code>, and the result will have a lower rank than <code><span class='Value'>𝕩</span></code>.</p>
+<p>Transpose also allows a left argument that specifies a permutation of <code><span class='Value'>𝕩</span></code>'s axes. For each index <code><span class='Value'>p</span><span class='Gets'>←</span><span class='Value'>i</span><span class='Function'>⊑</span><span class='Value'>𝕨</span></code> in the left argument, axis <code><span class='Value'>i</span></code> of <code><span class='Value'>𝕩</span></code> is used for axis <code><span class='Value'>p</span></code> of the result. Multiple argument axes can be sent to the same result axis, in which case that axis goes along a diagonal of <code><span class='Value'>𝕩</span></code>, and the result will have a lower rank than <code><span class='Value'>𝕩</span></code> (see the next section).</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omiIDHigL8z4oC/MuKAvzDigL80IOKNiSBhMjM0NTYKCuKJoiAx4oC/MuKAvzLigL8w4oC/MCDijYkgYTIzNDU2ICAjIERvbid0IHdvcnJ5IHRvbyBtdWNoIGFib3V0IHRoaXMgY2FzZSB0aG91Z2g=">↗️</a><pre> <span class='Function'>≢</span> <span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>4</span> <span class='Function'>⍉</span> <span class='Value'>a23456</span>
⟨ 5 2 4 3 6 ⟩
@@ -109,8 +109,26 @@
</span>⟨ 3 4 2 5 6 ⟩
</pre>
<p>Finally, it's worth noting that, as monadic Transpose moves the first axis to the end, it's equivalent to Reorder Axes with a &quot;default&quot; left argument: <code><span class='Paren'>(</span><span class='Function'>=-</span><span class='Number'>1</span><span class='Modifier'>˙</span><span class='Paren'>)</span><span class='Modifier2'>⊸</span><span class='Function'>⍉</span></code>.</p>
+<h3 id="taking-diagonals"><a class="header" href="#taking-diagonals">Taking diagonals</a></h3>
+<p>When <code><span class='Value'>𝕨</span></code> contains an axis index more than once, the corresponding axes of <code><span class='Value'>𝕩</span></code> will <em>all</em> be sent to that axis of the result. This isn't a special case: it follows the same rule that <code><span class='Value'>i</span><span class='Function'>⊑</span><span class='Value'>𝕨</span><span class='Function'>⍉</span><span class='Value'>𝕩</span></code> is <code><span class='Paren'>(</span><span class='Value'>𝕨</span><span class='Function'>⊏</span><span class='Value'>i</span><span class='Paren'>)</span><span class='Function'>⊑</span><span class='Value'>𝕩</span></code>. Only the result shape has to be adjusted for this case: the length along a result axis is the minimum of all the axes of <code><span class='Value'>𝕩</span></code> that go into it, because any indices outside this range will be out of bounds along at least one axis.</p>
+<p>A bit abstract. This rule is almost always used simply as <code><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Function'>⍉</span><span class='Value'>𝕩</span></code> to get the main diagonal of a matrix.</p>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIGEg4oaQIDPigL814qWKJ2EnK+KGlTE1Cgow4oC/MCDijYkgYQoK4p+oMuKfqeKKkTDigL8w4o2JYSAgIyBTaW5nbGUgaW5kZXggaW50byByZXN1bHQK4p+oMiwy4p+p4oqRYSAgICAjIGlzIGxpa2UgYSBkb3VibGVkIGluZGV4IGludG8gYQ==">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>a</span> <span class='Gets'>←</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>5</span><span class='Function'>⥊</span><span class='String'>'a'</span><span class='Function'>+↕</span><span class='Number'>15</span>
+┌─
+╵"abcde
+ fghij
+ klmno"
+ ┘
+
+ <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span> <span class='Function'>⍉</span> <span class='Value'>a</span>
+"agm"
+
+ <span class='Bracket'>⟨</span><span class='Number'>2</span><span class='Bracket'>⟩</span><span class='Function'>⊑</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Function'>⍉</span><span class='Value'>a</span> <span class='Comment'># Single index into result
+</span>'m'
+ <span class='Bracket'>⟨</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>2</span><span class='Bracket'>⟩</span><span class='Function'>⊑</span><span class='Value'>a</span> <span class='Comment'># is like a doubled index into a
+</span>'m'
+</pre>
<h2 id="definitions"><a class="header" href="#definitions">Definitions</a></h2>
<p>Here we define the two valences of Transpose more precisely.</p>
-<p>An atom right argument to either valence of Transpose is always enclosed to get an array before doing anything else.</p>
-<p>Monadic transpose is identical to <code><span class='Paren'>(</span><span class='Function'>=-</span><span class='Number'>1</span><span class='Modifier'>˙</span><span class='Paren'>)</span><span class='Modifier2'>⊸</span><span class='Function'>⍉</span></code>, except that if <code><span class='Value'>𝕩</span></code> is a unit it is returned unchanged (after enclosing, if it's an atom) rather than giving an error.</p>
-<p>In Reorder Axes, <code><span class='Value'>𝕨</span></code> is a number or numeric array of rank 1 or less, and <code><span class='Value'>𝕨</span><span class='Function'>≤</span><span class='Modifier2'>○</span><span class='Function'>≠≢</span><span class='Value'>𝕩</span></code>. Define the result rank <code><span class='Value'>r</span><span class='Gets'>←</span><span class='Paren'>(</span><span class='Function'>=</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>-+</span><span class='Modifier'>´</span><span class='Function'>¬∊</span><span class='Value'>𝕨</span></code> to be the right argument rank minus the number of duplicate entries in the left argument. We require <code><span class='Function'>∧</span><span class='Modifier'>´</span><span class='Value'>𝕨</span><span class='Function'>&lt;</span><span class='Value'>r</span></code>. Bring <code><span class='Value'>𝕨</span></code> to full length by appending the missing indices: <code><span class='Value'>𝕨</span><span class='Function'>∾</span><span class='Gets'>↩</span><span class='Value'>𝕨</span><span class='Paren'>(</span><span class='Function'>¬</span><span class='Modifier2'>∘</span><span class='Function'>∊</span><span class='Modifier'>˜</span><span class='Function'>/⊢</span><span class='Paren'>)</span><span class='Function'>↕</span><span class='Value'>r</span></code>. Now the result shape is defined to be <code><span class='Function'>⌊</span><span class='Modifier'>´¨</span><span class='Value'>𝕨</span><span class='Function'>⊔≢</span><span class='Value'>𝕩</span></code>. Element <code><span class='Value'>i</span><span class='Function'>⊑</span><span class='Value'>z</span></code> of the result <code><span class='Value'>z</span></code> is element <code><span class='Paren'>(</span><span class='Value'>𝕨</span><span class='Function'>⊏</span><span class='Value'>i</span><span class='Paren'>)</span><span class='Function'>⊑</span><span class='Value'>𝕩</span></code> of the argument.</p>
+<p>An atom right argument to Transpose or Reorder Axes is always <a href="enclose.html">enclosed</a> to get an array before doing anything else.</p>
+<p>Monadic Transpose is identical to <code><span class='Paren'>(</span><span class='Function'>=-</span><span class='Number'>1</span><span class='Modifier'>˙</span><span class='Paren'>)</span><span class='Modifier2'>⊸</span><span class='Function'>⍉</span></code>, except that if <code><span class='Value'>𝕩</span></code> is a unit it's returned unchanged (after enclosing, if it's an atom) rather than giving an error.</p>
+<p>In Reorder Axes, <code><span class='Value'>𝕨</span></code> is a number or numeric array of rank 1 or less, and <code><span class='Value'>𝕨</span><span class='Function'>≤</span><span class='Modifier2'>○</span><span class='Function'>≠≢</span><span class='Value'>𝕩</span></code>. Define the result rank <code><span class='Value'>r</span><span class='Gets'>←</span><span class='Paren'>(</span><span class='Function'>=</span><span class='Value'>𝕩</span><span class='Paren'>)</span><span class='Function'>-+</span><span class='Modifier'>´</span><span class='Function'>¬∊</span><span class='Value'>𝕨</span></code> to be the rank of <code><span class='Value'>𝕩</span></code> minus the number of duplicate entries in <code><span class='Value'>𝕨</span></code>. We require <code><span class='Function'>∧</span><span class='Modifier'>´</span><span class='Value'>𝕨</span><span class='Function'>&lt;</span><span class='Value'>r</span></code>. Bring <code><span class='Value'>𝕨</span></code> to full length by appending the missing indices: <code><span class='Value'>𝕨</span><span class='Function'>∾</span><span class='Gets'>↩</span><span class='Value'>𝕨</span><span class='Paren'>(</span><span class='Function'>¬</span><span class='Modifier2'>∘</span><span class='Function'>∊</span><span class='Modifier'>˜</span><span class='Function'>/⊢</span><span class='Paren'>)</span><span class='Function'>↕</span><span class='Value'>r</span></code>. Now the result shape is defined to be <code><span class='Function'>⌊</span><span class='Modifier'>´¨</span><span class='Value'>𝕨</span><span class='Function'>⊔≢</span><span class='Value'>𝕩</span></code>. Element <code><span class='Value'>i</span><span class='Function'>⊑</span><span class='Value'>z</span></code> of the result <code><span class='Value'>z</span></code> is element <code><span class='Paren'>(</span><span class='Value'>𝕨</span><span class='Function'>⊏</span><span class='Value'>i</span><span class='Paren'>)</span><span class='Function'>⊑</span><span class='Value'>𝕩</span></code> of the argument.</p>
diff --git a/docs/doc/types.html b/docs/doc/types.html
index 430aae1e..5dbab9bf 100644
--- a/docs/doc/types.html
+++ b/docs/doc/types.html
@@ -43,11 +43,11 @@
</svg>
<p>The reason operations and namespaces are called &quot;mutable&quot; is that the values obtained from them—by calling an operation on particular arguments or reading a field from a namespace—<a href="lexical.html#mutation">may change</a> over the course of the program. This property is caused by variable modification <code><span class='Gets'>↩</span></code>, which can directly change a namespace field, or change the behavior of an operation that uses the modified variable. This means that a program that doesn't include <code><span class='Gets'>↩</span></code> won't have such changes in behavior. However, there will still be an observable difference between immutable data and the mutable types: code that creates a mutable value (for example, a block function <code><span class='Brace'>{</span><span class='Value'>𝕩</span><span class='Brace'>}</span></code>) creates a different one each time, so that two different instances don't <a href="match.html">match</a> (<code><span class='Function'>≡</span></code>) each other. Data values created at different times may match, but mutable values never will.</p>
-<p>An array is considered immutable because its shape, and what elements it contains, cannot change. An array has no identity outside these properties (and possibly its <a href="fill.html">fill element</a>), so an array with a different shape or different elements would simply be a different array. However, any element of an array could be mutable, in which case the behavior of the array would change with respect to the operation of selecting that element and calling it or accessing a field.</p>
+<p>An array is considered immutable because its shape, and what elements it contains, cannot change. An array has no identity outside these properties (and possibly its <a href="fill.html">fill element</a>, which also can't change), so an array with a different shape or different elements would simply be a different array. However, any element of an array could be mutable, in which case the behavior of the array would change with respect to the operation of selecting that element and calling it or accessing a field.</p>
<h2 id="data-types"><a class="header" href="#data-types">Data types</a></h2>
<p>Data types—numbers, characters, and arrays—are more like &quot;things&quot; than &quot;actions&quot;. If called as a function, a value of one of these types simply returns itself. Data can be uniquely represented, compared for equality, and ordered using BQN's <a href="order.html#array-ordering">array ordering</a>; in contrast, determining whether two functions always return the same result can be undecidable. For arrays, these properties apply only if there are no operations inside. We might say that &quot;data&quot; in BQN refers to numbers, characters, and arrays of data.</p>
<h3 id="numbers"><a class="header" href="#numbers">Numbers</a></h3>
-<p>The BQN spec allows for different numeric models to be used, but requires there to be only one numeric type from the programmer's perspective: while programs can often be executed faster by using limited-range integer types, there is no need to expose these details to the programmer. Existing BQN implementations are based on <a href="https://en.wikipedia.org/wiki/IEEE-754">double-precision floats</a>, like Javascript or Lua.</p>
+<p>The BQN spec allows for different numeric models to be used, but requires there to be only one numeric type from the programmer's perspective: while programs can often be executed faster by using limited-range integer types, there is no need to expose these details to the programmer. Existing BQN implementations use <a href="https://en.wikipedia.org/wiki/IEEE-754">double-precision floats</a>, like Javascript or Lua.</p>
<h3 id="characters"><a class="header" href="#characters">Characters</a></h3>
<p>A character in BQN is always a <a href="https://en.wikipedia.org/wiki/Unicode">Unicode</a> code point. BQN does not use encodings such as UTF-8 or UTF-16 for characters, although it would be possible to store arrays of integers or characters that correspond to data in these encodings. Because every code point corresponds to a single unit in UTF-32, BQN characters can be thought of as UTF-32 encoded.</p>
<p>Addition and subtraction <a href="arithmetic.html#character-arithmetic">treat</a> characters as an <a href="http://videocortex.io/2018/Affine-Space-Types/">affine space</a> relative to the linear space of numbers. This means that:</p>
@@ -55,17 +55,17 @@
<li>A number can be added to or subtracted from a character.</li>
<li>Two characters can be subtracted to get the distance between them—a number.</li>
</ul>
-<p>Other linear combinations such as adding two characters or negating a character are not allowed. You can check whether an application of <code><span class='Function'>+</span></code> or <code><span class='Function'>-</span></code> on numbers and characters is allowed by applying the same function to the &quot;characterness&quot; of each value: <code><span class='Number'>0</span></code> for a number and <code><span class='Number'>1</span></code> for a character. The result will be a number if this application gives <code><span class='Number'>0</span></code> and a character if this gives <code><span class='Number'>1</span></code>, and otherwise the operation is not allowed.</p>
+<p>Other linear combinations such as adding two characters or negating a character are not allowed. You can check whether an application of <code><span class='Function'>+</span></code> or <code><span class='Function'>-</span></code> on numbers and characters is allowed by applying the same function to the &quot;characterness&quot; of each value: 0 for a number and 1 for a character. The result will be a number if the application gives 0 and a character if it gives 1, and otherwise the operation is not allowed.</p>
<h3 id="arrays"><a class="header" href="#arrays">Arrays</a></h3>
<p><em><a href="array.html">Full documentation</a>.</em></p>
-<p>A BQN array is a multidimensional arrangement of data. This means it has a certain <a href="shape.html"><em>shape</em></a>, which is a finite list of natural numbers giving the length along each axis, and it contains an <em>element</em> for each possible <a href="indices.html"><em>index</em></a>, which is a choice of one natural number that's less than each axis length in the shape. The total number of elements, or <em>bound</em>, is then the product of all the lengths in the shape. The shape may have any length including zero, and this shape is known as the array's <em>rank</em>. An array of rank 0, which always contains exactly one element, is called a <em>unit</em>, while an array of rank 1 is called a <em>list</em> and an array of rank 2 is called a <em>table</em>.</p>
+<p>A BQN array is a multidimensional arrangement of data. This means it has a certain <a href="shape.html"><em>shape</em></a>, which is a finite list of natural numbers giving the length along each axis, and it contains an <em>element</em> for each possible <a href="indices.html"><em>index</em></a>, which is a choice of one natural number that's less than each axis length in the shape. The total number of elements, or <em>bound</em>, is then the product of all the lengths in the shape. The shape may have any length including zero, and this shape is known as the array's <em>rank</em>. An array of rank 0, which always contains exactly one element, is called a <a href="enclose.html#whats-a-unit"><em>unit</em></a>, while an array of rank 1 is called a <em>list</em> and an array of rank 2 is called a <em>table</em>.</p>
<p>Each array—empty or nonempty—has an inferred property called a <a href="fill.html"><em>fill</em></a>. The fill either indicates what element should be used to pad an array, or that such an element is not known and an error should result. Fills can be used by <a href="take.html">Take</a> (<code><span class='Function'>↑</span></code>), the two <a href="shift.html">Nudge</a> functions (<code><span class='Function'>»«</span></code>), <a href="couple.html">Merge</a> (<code><span class='Function'>&gt;</span></code>), and <a href="reshape.html">Reshape</a> (<code><span class='Function'>⥊</span></code>).</p>
-<p>Arrays are value types (or immutable), so that there is no way to &quot;change&quot; the shape or elements of an array. An array with different properties is a different array. As a consequence, arrays are an inductive type, and it's not possible for an array to contain itself, or contain an array that contains itself, and so on. However, it is possible for an array to contain a function or other operation that has access to the array through a variable, and in this sense an array can &quot;know about&quot; itself.</p>
+<p>Arrays are value types (or immutable), so that there is no way to &quot;change&quot; the shape or elements of an array. An array with different properties is a different array. As a consequence, arrays are an inductive type, and it's not possible for an array to contain itself, or contain an array that contains itself, and so on. However, it is possible for an array to contain a function or other mutable value that has access to the array through a variable, and in this sense an array can &quot;know about&quot; itself.</p>
<p>Different elements of an array should not influence each other. While some APLs force numbers placed in the same array to a common representation, which may have different precision properties, BQN values must not change behavior when placed in an array. However, this doesn't preclude changing the storage type of an array for better performance: for example, in a BQN implementation using 64-bit floats, an array whose elements are all integers that fit in 32-bit int range might be represented as an array of 32-bit ints.</p>
<h2 id="operation-types"><a class="header" href="#operation-types">Operation types</a></h2>
<p><em><a href="ops.html">Full documentation</a>.</em></p>
<p>An operation is either a function or modifier, and can be applied to <em>inputs</em>—which are called <em>arguments</em> for functions and <em>operands</em> for modifiers—to obtain a result. During this application an operation might also change variables within its scope and call other operations, or cause an error, in which case it doesn't return a result. There is one type of call for each of the three operation types, and an operation will give an error if it is called in a way that doesn't match its type.</p>
-<p>In BQN syntax the result of a function has a subject role and the result of a modifier has a function role. However, the result can be any value at all: roles take place at the syntactic level, which has no bearing on types and values in the semantic level. This distinction is discussed further in <a href="context.html#mixing-roles">Mixing roles</a>.</p>
+<p>In BQN syntax the result of function application has a subject role and the result of modifier application has a function role. However, the result value can still be anything at all: roles apply at the syntactic level, which has no bearing on types and values in the semantic level. This distinction is discussed further in <a href="context.html#mixing-roles">Mixing roles</a>.</p>
<h3 id="functions"><a class="header" href="#functions">Functions</a></h3>
<p>A function is called with one or two arguments. A data value (number, character, or array) can also be called the same way, but only a function takes any action when passed arguments, as data just returns itself. Both the one-argument and two-argument calls are considered function calls, and it's common for a function to allow both. A function that always errors in one case or the other might be called a one-argument or two-argument function, depending on which case is allowed.</p>
<h3 id="modifiers"><a class="header" href="#modifiers">Modifiers</a></h3>