aboutsummaryrefslogtreecommitdiff
path: root/docs/doc/under.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doc/under.html')
-rw-r--r--docs/doc/under.html12
1 files changed, 6 insertions, 6 deletions
diff --git a/docs/doc/under.html b/docs/doc/under.html
index ae931d47..2a06e458 100644
--- a/docs/doc/under.html
+++ b/docs/doc/under.html
@@ -57,15 +57,15 @@
0 10 11
</pre>
-<p>When used with Under, the function <code><span class='Number'>1</span><span class='Modifier2'>⊸</span><span class='Function'>⌽</span></code> applies to the first column, rotating it. The result of <code><span class='Function'>𝔽</span></code> needs to be compatible with the selection function, so Rotate works but trying to remove an element is no good:</p>
+<p>When used with Under, the function <code><span class='Number'>1</span><span class='Modifier2'>⊸</span><span class='Function'>⌽</span></code> applies to the first column, <a href="reverse.html#rotate">rotating</a> it. The result of <code><span class='Function'>𝔽</span></code> needs to be compatible with the selection function, so Rotate works but trying to drop an element is no good:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MeKKuOKGk+KMvijiio/LmCkgYQ==">↗️</a><pre> <span class='Number'>1</span><span class='Modifier2'>⊸</span><span class='Function'>↓</span><span class='Modifier2'>⌾</span><span class='Paren'>(</span><span class='Function'>⊏</span><span class='Modifier'>˘</span><span class='Paren'>)</span> <span class='Value'>a</span>
<span class='Error'>Error: ⁼: Inverse not found</span>
</pre>
-<p>BQN can detect lots of structural functions when written in <a href="tacit.html">tacit</a> form; see the list of functions <a href="../spec/inferred.html#required-structural-inverses">in the spec</a>. You can also include computations on the shape. For example, here's a function to reverse the first half of a list.</p>
+<p>BQN can detect lots of structural functions when written <a href="tacit.html">tacitly</a>; see the list of recognized forms <a href="../spec/inferred.html#required-structural-inverses">in the spec</a>. You can also include computations on the shape. For example, here's a function to reverse the first half of a list.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oy94oy+KOKKouKGkcuc4omgw7cyy5kpICJhYmNkZWYi">↗️</a><pre> <span class='Function'>⌽</span><span class='Modifier2'>⌾</span><span class='Paren'>(</span><span class='Function'>⊢↑</span><span class='Modifier'>˜</span><span class='Function'>≠÷</span><span class='Number'>2</span><span class='Modifier'>˙</span><span class='Paren'>)</span> <span class='String'>&quot;abcdef&quot;</span>
"cbadef"
</pre>
-<p>But you can't use a computation that uses array values, such as <code><span class='Number'>10</span><span class='Modifier2'>⊸</span><span class='Function'>+</span><span class='Modifier2'>⌾</span><span class='Paren'>((</span><span class='Function'>&lt;</span><span class='Modifier2'>⊸</span><span class='Number'>5</span><span class='Paren'>)</span><span class='Modifier2'>⊸</span><span class='Function'>/</span><span class='Paren'>)</span></code> to add 10 to each element below 5. This is because Under can change the array values, so that the function <code><span class='Function'>𝔾</span></code> doesn't select the same elements before and after applying it (at the same time, Under can't change array structure, or at least not the parts that matter to <code><span class='Function'>𝔾</span></code>). To use a dynamic selection function, compute the mask or indices based on a copy of the argument and use those as part of <code><span class='Function'>𝔾</span></code>.</p>
+<p>But you can't use a computation that uses array values, such as <code><span class='Number'>10</span><span class='Modifier2'>⊸</span><span class='Function'>+</span><span class='Modifier2'>⌾</span><span class='Paren'>((</span><span class='Function'>&lt;</span><span class='Modifier2'>⊸</span><span class='Number'>5</span><span class='Paren'>)</span><span class='Modifier2'>⊸</span><span class='Function'>/</span><span class='Paren'>)</span></code> to add 10 to each element below 5. This is because Under can change the array values, so that the function <code><span class='Function'>𝔾</span></code> doesn't select the same elements before and after applying it (contrarily, Under can't change array structure, or at least not the parts that matter to <code><span class='Function'>𝔾</span></code>). To use a dynamic selection function, compute the mask or indices based on a copy of the argument and use those as part of <code><span class='Function'>𝔾</span></code>.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ezEw4oq4K+KMvigo8J2VqTw1KeKKuC8p8J2VqX0gM+KAvzjigL8y4oC/MuKAvzYKCig84p+cNSniirgvIDPigL844oC/MuKAvzLigL82CgooPOKfnDUp4oq4LyB7MTDiirgr4oy+KCjwnZWpPDUp4oq4LynwnZWpfSAz4oC/OOKAvzLigL8y4oC/Ng==">↗️</a><pre> <span class='Brace'>{</span><span class='Number'>10</span><span class='Modifier2'>⊸</span><span class='Function'>+</span><span class='Modifier2'>⌾</span><span class='Paren'>((</span><span class='Value'>𝕩</span><span class='Function'>&lt;</span><span class='Number'>5</span><span class='Paren'>)</span><span class='Modifier2'>⊸</span><span class='Function'>/</span><span class='Paren'>)</span><span class='Value'>𝕩</span><span class='Brace'>}</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>8</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>6</span>
⟨ 13 8 12 12 6 ⟩
@@ -89,14 +89,14 @@
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oyK4oy+KDEw4oq4w5cpIDMuNTI04oC/Ni43OTnigL8yLjAzMQ==">↗️</a><pre> <span class='Function'>⌊</span><span class='Modifier2'>⌾</span><span class='Paren'>(</span><span class='Number'>10</span><span class='Modifier2'>⊸</span><span class='Function'>×</span><span class='Paren'>)</span> <span class='Number'>3.524</span><span class='Ligature'>‿</span><span class='Number'>6.799</span><span class='Ligature'>‿</span><span class='Number'>2.031</span>
⟨ 3.5 6.7 2 ⟩
</pre>
-<p>See how it works? <code><span class='Function'>⌊</span></code> rounds down to an integer, but we can get it to round down to a decimal by first multiplying by 10 (single decimals are now integers), then rounding, then undoing that multiplication. A related idea is to not just round but produce a range. Suppose I want the arithmetic progression 4, 7, 10, ... &lt;20. If I had the right range <code><span class='Function'>↕</span><span class='Value'>n</span></code>, then it would be <code><span class='Number'>4</span><span class='Function'>+</span><span class='Number'>3</span><span class='Function'>×↕</span><span class='Value'>n</span></code>, or <code><span class='Paren'>(</span><span class='Number'>4</span><span class='Function'>+</span><span class='Number'>3</span><span class='Function'>×⊢</span><span class='Paren'>)</span><span class='Function'>↕</span><span class='Value'>n</span></code>. By using the <em>inverse</em> of this transformation function on the desired endpoint, I can make sure it's applied on the way out, and BQN figures out what to do on the way in as if by magic.</p>
+<p>See how it works? <code><span class='Function'>⌊</span></code> rounds down to an integer, but we can get it to round down to a decimal by first multiplying by 10 (so that single decimals become integers), then rounding, then undoing that multiplication. A related idea is to not just round but produce a range. Suppose I want the arithmetic progression 4, 7, 10, ... &lt;20. If I had the right range <code><span class='Function'>↕</span><span class='Value'>n</span></code>, then it would be <code><span class='Number'>4</span><span class='Function'>+</span><span class='Number'>3</span><span class='Function'>×↕</span><span class='Value'>n</span></code>, or <code><span class='Paren'>(</span><span class='Number'>4</span><span class='Function'>+</span><span class='Number'>3</span><span class='Function'>×⊢</span><span class='Paren'>)</span><span class='Function'>↕</span><span class='Value'>n</span></code>. By using the <em>inverse</em> of this transformation function on the desired endpoint, I can make sure it's applied on the way out, and BQN figures out what to do on the way in as if by magic.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oaV4oiY4oyI4oy+KCg0KzPDl+KKoinigbwpIDIw">↗️</a><pre> <span class='Function'>↕</span><span class='Modifier2'>∘</span><span class='Function'>⌈</span><span class='Modifier2'>⌾</span><span class='Paren'>((</span><span class='Number'>4</span><span class='Function'>+</span><span class='Number'>3</span><span class='Function'>×⊢</span><span class='Paren'>)</span><span class='Modifier'>⁼</span><span class='Paren'>)</span> <span class='Number'>20</span>
⟨ 4 7 10 13 16 19 ⟩
</pre>
-<p>Well, really it's a bit of simple algebra, but if it wants to wear a pointy hat and wave a wand around I won't judge.</p>
+<p>Well, really it's some simple algebra, but if it wants to wear a pointy hat and wave a wand around I won't judge.</p>
<h2 id="left-argument"><a class="header" href="#left-argument">Left argument</a></h2>
<p>When called dyadically, Under applies <code><span class='Function'>𝔽</span></code> dyadically, like <a href="compose.html#over">Over</a>. This doesn't affect the undoing part of Under, which still tries to put the result of <code><span class='Function'>𝔽</span></code> back into <code><span class='Value'>𝕩</span></code> for structural Under or invert <code><span class='Function'>𝔾</span></code> for computational. In fact, <code><span class='Value'>𝕨</span> <span class='Function'>𝔽</span><span class='Modifier2'>⌾</span><span class='Function'>𝔾</span> <span class='Value'>𝕩</span></code> is equivalent to <code><span class='Paren'>(</span><span class='Function'>𝔾</span><span class='Value'>𝕨</span><span class='Paren'>)</span><span class='Modifier'>˙</span><span class='Modifier2'>⊸</span><span class='Function'>𝔽</span><span class='Modifier2'>⌾</span><span class='Function'>𝔾</span> <span class='Value'>𝕩</span></code> so no exciting language stuff is happening here at all.</p>
-<p>But you can still do some cool stuff with it! One pattern is simply to set <code><span class='Function'>𝔽</span></code> to <code><span class='Function'>⊣</span></code>, the <a href="identity.html">identity</a> function that just returns its left argument. Now structural Under will replace everything that <code><span class='Function'>𝔾</span></code> selects from <code><span class='Value'>𝕩</span></code> with the corresponding values in <code><span class='Value'>𝕨</span></code>. Here's an example that replaces elements with indices <code><span class='Number'>1</span></code> and <code><span class='Number'>2</span></code>.</p>
+<p>But you can still do cool things with it! One pattern is simply to set <code><span class='Function'>𝔽</span></code> to <code><span class='Function'>⊣</span></code>, the <a href="identity.html">identity</a> function that just returns its left argument. Now structural Under will replace everything that <code><span class='Function'>𝔾</span></code> selects from <code><span class='Value'>𝕩</span></code> with the corresponding values in <code><span class='Value'>𝕨</span></code>. Here's an example that replaces elements with indices <code><span class='Number'>1</span></code> and <code><span class='Number'>2</span></code>.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ImFiY2QiIOKKo+KMvigx4oC/MuKKuOKKjykgIjAxMjMi">↗️</a><pre> <span class='String'>&quot;abcd&quot;</span> <span class='Function'>⊣</span><span class='Modifier2'>⌾</span><span class='Paren'>(</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Modifier2'>⊸</span><span class='Function'>⊏</span><span class='Paren'>)</span> <span class='String'>&quot;0123&quot;</span>
"0bc3"
</pre>