aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-08-12 09:33:39 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-08-12 09:33:39 -0400
commit8afd6d6d22e3b123423a95eae1389c3fa942a066 (patch)
treea74759e367ce3d132536d2023cbf5416cba99c5b
parent5cf01779b86ed6808ca336cdc87e98be8497404b (diff)
Fix broken sentence
-rw-r--r--commentary/overload.md2
-rw-r--r--docs/commentary/overload.html2
2 files changed, 2 insertions, 2 deletions
diff --git a/commentary/overload.md b/commentary/overload.md
index 0adcc25d..bb2dee41 100644
--- a/commentary/overload.md
+++ b/commentary/overload.md
@@ -36,7 +36,7 @@ There are examples outside the array world that I find worse than anything in BQ
Sometimes what seems like an extension can be unified into a single more general primitive. For example, APL has [scalar extension](https://aplwiki.com/wiki/Scalar_extension) to allow you to add, say, a scalar to a list in `1 + 2‿3‿4`. J and BQN use the more general [leading axis agreement](../doc/leading.md#leading-axis-agreement), which has this extension as a special case (although incidentally, BQN removes some unprincipled extension of list-like functions like Reverse to rank-0 arguments). Character arithmetic can also be viewed in this way considering numbers and characters to be pairs of "characterness" 0 or 1, and a numeric value.
-I think many primitive pairs, such as `-`, `⋆`, `«`, `⥊`, and `⍉`, fall into this category too. Primitives like can be described as a general dyadic function, and a monadic case that comes from a default left argument (sometimes dependent on the right argument: it's `(=𝕩)-1` for `⍉`). The primitive `⋈` is so tight it might be considered a fully compatible overload, returning a list of all arguments. Such primitive pairs can sometimes be used ambivalently in simple ways (`⋆⁼` is pretty nice), but more often the usefulness is just that it's easier to think about each pair as one thing rather than two. It's just two views of the same idea.
+I think many primitive pairs, such as `-`, `⋆`, `«`, `⥊`, and `⍉`, fall into this category too. These can all be described as a general dyadic function, and a monadic case that comes from a default left argument (sometimes dependent on the right argument: it's `(=𝕩)-1` for `⍉`). The primitive `⋈` is so tight it might be considered a fully compatible overload, returning a list of all arguments. Such primitive pairs can sometimes be used ambivalently in simple ways (`⋆⁼` is pretty nice), but more often the usefulness is just that it's easier to think about each pair as one thing rather than two. It's just two views of the same idea.
## Mnemonic overloading
diff --git a/docs/commentary/overload.html b/docs/commentary/overload.html
index f45771f1..b5ab0f3e 100644
--- a/docs/commentary/overload.html
+++ b/docs/commentary/overload.html
@@ -26,7 +26,7 @@
<p>If that was all, it would hardly be worth mentioning. A more significant family of extensions is the <a href="../doc/depth.html#testing-depth-for-multiple-axis-primitives">use of depth</a> to allow a primitive to work on multiple axes in general but also to have a convenient one-axis form. Then there's <a href="../doc/arithmetic.html#character-arithmetic">character arithmetic</a>, allowing <code><span class='String'>'a'</span> <span class='Function'>+</span> <span class='Number'>3</span></code>. In fact, isn't array arithmetic itself a big extension?</p>
<p>There are examples outside the array world that I find worse than anything in BQN. <code><span class='Function'>+</span></code> for string catenation. This no longer obeys commutativity or distributivity: it's not safe to rearrange <code><span class='Value'>a</span> <span class='Function'>+</span> <span class='Value'>b</span></code> to <code><span class='Value'>b</span> <span class='Function'>+</span> <span class='Value'>a</span></code> or <code><span class='Paren'>(</span><span class='Value'>a</span><span class='Function'>+</span><span class='Value'>b</span><span class='Paren'>)</span><span class='Value'>*c</span></code> to <code><span class='Paren'>(</span><span class='Value'>a*c</span><span class='Paren'>)</span><span class='Function'>+</span><span class='Paren'>(</span><span class='Value'>b*c</span><span class='Paren'>)</span></code> in languages that do this! NumPy and MATLAB allow a boolean array to be used as an index, performing filtering. This one doesn't obey the rule that the length of <code><span class='Value'>a</span><span class='Bracket'>[</span><span class='Value'>b</span><span class='Bracket'>]</span></code> is the length of <code><span class='Value'>b</span></code>, or any other length-based rules really.</p>
<p>Sometimes what seems like an extension can be unified into a single more general primitive. For example, APL has <a href="https://aplwiki.com/wiki/Scalar_extension">scalar extension</a> to allow you to add, say, a scalar to a list in <code><span class='Number'>1</span> <span class='Function'>+</span> <span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span></code>. J and BQN use the more general <a href="../doc/leading.html#leading-axis-agreement">leading axis agreement</a>, which has this extension as a special case (although incidentally, BQN removes some unprincipled extension of list-like functions like Reverse to rank-0 arguments). Character arithmetic can also be viewed in this way considering numbers and characters to be pairs of &quot;characterness&quot; 0 or 1, and a numeric value.</p>
-<p>I think many primitive pairs, such as <code><span class='Function'>-</span></code>, <code><span class='Function'>⋆</span></code>, <code><span class='Function'>«</span></code>, <code><span class='Function'>⥊</span></code>, and <code><span class='Function'>⍉</span></code>, fall into this category too. Primitives like can be described as a general dyadic function, and a monadic case that comes from a default left argument (sometimes dependent on the right argument: it's <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></code> for <code><span class='Function'>⍉</span></code>). The primitive <code><span class='Function'>⋈</span></code> is so tight it might be considered a fully compatible overload, returning a list of all arguments. Such primitive pairs can sometimes be used ambivalently in simple ways (<code><span class='Function'>⋆</span><span class='Modifier'>⁼</span></code> is pretty nice), but more often the usefulness is just that it's easier to think about each pair as one thing rather than two. It's just two views of the same idea.</p>
+<p>I think many primitive pairs, such as <code><span class='Function'>-</span></code>, <code><span class='Function'>⋆</span></code>, <code><span class='Function'>«</span></code>, <code><span class='Function'>⥊</span></code>, and <code><span class='Function'>⍉</span></code>, fall into this category too. These can all be described as a general dyadic function, and a monadic case that comes from a default left argument (sometimes dependent on the right argument: it's <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></code> for <code><span class='Function'>⍉</span></code>). The primitive <code><span class='Function'>⋈</span></code> is so tight it might be considered a fully compatible overload, returning a list of all arguments. Such primitive pairs can sometimes be used ambivalently in simple ways (<code><span class='Function'>⋆</span><span class='Modifier'>⁼</span></code> is pretty nice), but more often the usefulness is just that it's easier to think about each pair as one thing rather than two. It's just two views of the same idea.</p>
<h2 id="mnemonic-overloading"><a class="header" href="#mnemonic-overloading">Mnemonic overloading</a></h2>
<p>Okay, we are slipping down the slope nicely, now what about the primitives where the two halves don't quite do the same thing? Take <code><span class='Function'>∾</span></code> to start smoothly. The dyadic form joins two lists and the monadic form joins a list of lists. Well, this is really one function that takes its arguments in a slightly unusual way, since dyadic <code><span class='Function'>∾</span></code> is <code><span class='Function'>∾</span><span class='Modifier2'>∘</span><span class='Function'>⋈</span></code>. The primitive <code><span class='Function'>↑</span></code> for Prefixes/Take (<code><span class='Function'>↓</span></code> too) is similar, but in a trickier way: if <code><span class='Value'>𝕨</span></code> is between <code><span class='Number'>0</span></code> and <code><span class='Function'>≠</span><span class='Value'>𝕩</span></code>, <code><span class='Value'>𝕨</span><span class='Function'>↑</span><span class='Value'>𝕩</span></code> is a prefix of <code><span class='Value'>𝕩</span></code>. Then <code><span class='Function'>↑</span></code> is the list of all these prefixes, so <code><span class='Value'>𝕨</span><span class='Function'>⊑↑</span><span class='Value'>𝕩</span></code> is <code><span class='Value'>𝕨</span><span class='Function'>↑</span><span class='Value'>𝕩</span></code>. It's almost a kind of partial application.</p>
<p>These primitives are easier to remember in the same way that it's much easier to memorize just <code><span class='Function'>⊏</span></code> instead of a select function and a separate first-cell function. If I weren't allowed to overload them together, I probably just wouldn't include monadic <code><span class='Function'>↑↓⊏</span></code> (or <code><span class='Function'>√⋆</span></code>, even <code><span class='Function'>-</span></code>?), and maybe not even dyadic <code><span class='Function'>∾</span></code>.</p>