summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-07-24 16:04:24 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-07-24 16:04:24 -0400
commit1045ede124fc60de41f273d7997521d386c82bf1 (patch)
treed6675707151b8ad73eb1c1935cfcd6083c27a6b1
parent7b96b5911e7aa4e542f7f0ea472f71fb7857abe6 (diff)
Editing pass over first two tutorials
-rw-r--r--docs/tutorial/expression.html25
-rw-r--r--docs/tutorial/list.html23
-rw-r--r--tutorial/expression.md23
-rw-r--r--tutorial/list.md21
4 files changed, 48 insertions, 44 deletions
diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html
index 3708dc95..9ce866a7 100644
--- a/docs/tutorial/expression.html
+++ b/docs/tutorial/expression.html
@@ -119,7 +119,7 @@
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KDTDtzMpIMOXIM+AIMOXIDLii4Yz">↗️</a><pre> <span class='Paren'>(</span><span class='Number'>4</span><span class='Function'>÷</span><span class='Number'>3</span><span class='Paren'>)</span> <span class='Function'>×</span> <span class='Number'>π</span> <span class='Function'>×</span> <span class='Number'>2</span><span class='Function'>⋆</span><span class='Number'>3</span>
33.51032163829112
</pre>
-<p>The evaluation order is diagrammed below, with the function <code><span class='Function'>⋆</span></code> on the first line evaluated first, then <code><span class='Function'>×</span></code> on the next, and so on. The effect of the parentheses is that <code><span class='Function'>÷</span></code> is evaluated before the leftmost <code><span class='Function'>×</span></code>.</p>
+<p>The evaluation order is diagrammed below, with the function <code><span class='Function'>⋆</span></code> at the highest level evaluated first, then <code><span class='Function'>×</span></code> below it, and so on. The effect of the parentheses is that <code><span class='Function'>÷</span></code> is evaluated before the leftmost <code><span class='Function'>×</span></code>.</p>
<svg viewBox='-174.7 -34 512 188'>
<g font-family='BQN,monospace' font-size='18px' class='Paren' fill='currentColor'>
<rect class='code' stroke-width='1' rx='10' x='-21.68' y='-24' width='205.96' height='168'/>
@@ -223,21 +223,21 @@
</g>
</svg>
-<p>But wait: how do we know that <code><span class='Function'>√</span></code> in the expressions above uses the one-argument form? Remember that it can also take a left argument. For that matter, how do we know that <code><span class='Function'>-</span></code> takes two arguments and not just one? Maybe this looks trivial right now: a good enough answer while we're only doing arithmetic is that a function is called with one argument if there is nothing to its left, or another function, and with two arguments otherwise. But it will get more complicated as we expand the syntax with expressions that can return functions and so on, so it's a good idea to discuss the foundations that will allow us to handle that complexity. In BQN, the way expressions are evaluated—the sequence of function calls and other operations—is determined by the <em>syntactic role</em> of the things it contains. A few rules of roles make sense of the syntax seen so far:</p>
+<p>But wait: how do we know that <code><span class='Function'>√</span></code> in the expressions above uses the one-argument form? Remember that it can also take a left argument. For that matter, how do we know that <code><span class='Function'>-</span></code> takes two arguments and not just one? Maybe this looks trivial right now: a good enough answer while we're only doing arithmetic is that a function is called with one argument if there is nothing to its left, or another function, and with two arguments otherwise. But it'll get more complicated as we expand the syntax with expressions that can return functions and so on, so it's a good idea to discuss the foundations that will allow us to handle that complexity. In BQN, the way expressions are evaluated—the sequence of function calls and other operations—is determined by the <em>syntactic role</em> of the things it contains. A few rules of roles make sense of the syntax seen so far:</p>
<ul>
<li><em>Numeric literals</em> such as <code><span class='Number'>1</span></code> and <code><span class='Number'>π</span></code> are <em>subjects</em>.</li>
<li><em>Primitive functions</em> are <em>functions</em> (gasp).</li>
-<li>A function's arguments are subjects. To call a function it must have a subject on the right, and may have a subject on the left, which is used as the left argument.</li>
+<li>A function's arguments are subjects. To call a function it must have a subject on the right, and may have a subject on the left, which becomes the left argument.</li>
<li>A function's result is a subject—or, more precisely, a function call expression is a subject.</li>
<li>A set of parentheses has the same role as whatever's inside it.</li>
</ul>
-<p>Perhaps more than you thought! To really get roles, it's important to understand that a role is properly a property of an expression, and not its value. In language implementation terms, roles are used only to parse expressions, giving a syntax tree, but don't dictate what values are possible when the tree is evaluated. So it's possible to have a function with a number role or a number with a function role. The reason this doesn't happen with the numeric literals and primitives we've introduced is that these tokens have a constant value. <code><span class='Function'>×</span></code> or <code><span class='Number'>∞</span></code> have the same value in any possible program, and so it makes sense that their types and roles should correspond. When we introduce identifiers, we'll see this correspondence break down—and why that's good!</p>
+<p>Perhaps more than you thought! To really get roles, it's important to understand that a role is properly a property of an expression, and not its value. In language implementation terms, roles are used only to parse expressions, giving a syntax tree, but don't dictate what values may appear when the tree is evaluated. So it's possible to have a function with a number role or a number with a function role. The reason this doesn't happen with the numeric literals and primitives we've introduced is that these tokens have a constant value. <code><span class='Function'>×</span></code> or <code><span class='Number'>∞</span></code> have the same value in any possible program, and so it makes sense that their types and roles should correspond. When we introduce identifiers, we'll see this correspondence break down—and why that's good!</p>
<h2 id="character-arithmetic"><a class="header" href="#character-arithmetic">Character arithmetic</a></h2>
<p>Gosh, that's a lot of arithmetic up there. Maybe adding characters will mix things up a bit? Hang on, you can't add characters, only subtract them… let's back up.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=J2Mn">↗️</a><pre> <span class='String'>'c'</span>
'c'
</pre>
-<p>A character is written with single quotes. As in the C language, it's not the same as a string, which is written with double quotes. There are no escapes for characters: any source code character between single quotes becomes a character literal, even a newline. Some kinds of arithmetic e<a href="https://xkcd.com/1537/">x</a>tend to characters:</p>
+<p>A character is written with single quotes. As in the C language, it's not the same as a string, which is written with double quotes. There are no character escapes: any source code character between single quotes becomes a character literal, even a newline. Some kinds of arithmetic e<a href="https://xkcd.com/1537/">x</a>tend to characters:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=J2MnICsgMQonaCcgLSAnYSc=">↗️</a><pre> <span class='String'>'c'</span> <span class='Function'>+</span> <span class='Number'>1</span>
'd'
<span class='String'>'h'</span> <span class='Function'>-</span> <span class='String'>'a'</span>
@@ -285,7 +285,7 @@
<p>It's a convenient way to write non-printing characters without having to include them in your source code: for example <code><span class='String'>@</span><span class='Function'>+</span><span class='Number'>10</span></code> is the newline character.</p>
<p>Addition and subtraction with affine characters have all the same algebraic properties that they do with numbers. One way to see this is to think of values as a combination of &quot;characterness&quot; (0 for numbers and 1 for characters) and either numeric value or code point. Addition and subtraction are done element-wise on these pairs of numbers, and are allowed if the result is a valid value, that is, its characterness is 0 or 1 and its value is a valid code point if the characterness is 1. However, because the space of values is no longer closed under addition and subtraction, certain rearrangements of valid computations might not work, if one of the values produced in the middle isn't legal.</p>
<h2 id="modifiers"><a class="header" href="#modifiers">Modifiers</a></h2>
-<p>Functions are nice and all, but to really bring us into the space age BQN has a second level of function called <em>modifiers</em> (the space age in this case is when operators were introduced to APL in the early 60s—hey, did you know the <a href="https://aplwiki.com/wiki/APL_conference#1970">second APL conference</a> was held at Goddard Space Flight Center?). While functions apply to subjects, modifiers can apply to functions <em>or</em> subjects, and return functions. For example, the 1-modifier <code><span class='Modifier'>˜</span></code> modifies one function—that's where the 1 comes from—by swapping the arguments before calling it (Swap), or copying the right argument to the left if there's only one (Self).</p>
+<p>Functions are nice and all, but to really bring us into the space age BQN has a second level of function called <em>modifiers</em> (the space age in this case is when operators were introduced to APL in the early 60s—hey, did you know the <a href="https://aplwiki.com/wiki/APL_conference#1970">second APL conference</a> was held at Goddard Space Flight Center?). While functions apply to subjects, modifiers apply to functions <em>or</em> subjects, and return functions. For example, the 1-modifier <code><span class='Modifier'>˜</span></code> modifies one function—that's where the 1 comes from—by swapping the arguments before calling it (Swap), or copying the right argument to the left if there's only one (Self).</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiAty5wgJ2QnICAjIFN1YnRyYWN0IGZyb20KK8ucIDMgICAgICAjIEFkZCB0byBpdHNlbGY=">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>-</span><span class='Modifier'>˜</span> <span class='String'>'d'</span> <span class='Comment'># Subtract from
</span>'b'
<span class='Function'>+</span><span class='Modifier'>˜</span> <span class='Number'>3</span> <span class='Comment'># Add to itself
@@ -317,13 +317,14 @@
</tr>
</table>
-<p>Another 1-modifier is Undo (<code><span class='Modifier'>⁼</span></code>). BQN has just enough computer algebra facilities to look like a tool for Neanderthals next to a real computer algebra system, and among them is the ability to invert some primitives. In general you can't be sure when Undo will work (it might even be undecidable), but the examples I'll give here are guaranteed by <a href="../spec/inferred.html#undo">the spec</a> to always work in the same way. Starting with a <em>third</em> way to square a number:</p>
+<p>Another 1-modifier is Undo (<code><span class='Modifier'>⁼</span></code>). BQN has just enough computer algebra facilities to look like a tool for Neanderthals next to a real computer algebra system, and among them is the ability to invert some primitives. Undo has a <a href="../spec/inferred.html#undo">specification</a> that fixes results for some functions and modifiers, but allows implementations to go further. In the tutorials we'll stick to the required stuff, which is definitely enough to be practically useful. Starting with a <em>third</em> way to square a number:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oia4oG8IDQ=">↗️</a><pre> <span class='Function'>√</span><span class='Modifier'>⁼</span> <span class='Number'>4</span>
16
</pre>
<p>But the most important use for Undo in arithmetic is the logarithm, written <code><span class='Function'>⋆</span><span class='Modifier'>⁼</span></code>. That's all a logarithm is: it undoes the Power function! With no left argument <code><span class='Function'>⋆</span><span class='Modifier'>⁼</span></code> is the natural logarithm. If there's a left argument then Undo considers it part of the function to be undone. The result in this case is that <code><span class='Function'>⋆</span><span class='Modifier'>⁼</span></code> with two arguments is the logarithm of the right argument with base given by the left one.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4ouG4oG8IDEwCjIg4ouG4oG8IDMyICAgICMgTG9nIGJhc2UgMgoyIOKLhiAyIOKLhuKBvCAzMgoxMCDii4bigbwgMWU0ICAjIExvZyBiYXNlIDEwIG9mIGEgbnVtYmVyIGluIHNjaWVudGlmaWMgbm90YXRpb24=">↗️</a><pre> <span class='Function'>⋆</span><span class='Modifier'>⁼</span> <span class='Number'>10</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4ouG4oG8IDEwCgoyIOKLhuKBvCAzMiAgICAjIExvZyBiYXNlIDIKMiDii4YgMiDii4bigbwgMzIKMTAg4ouG4oG8IDFlNCAgIyBMb2cgYmFzZSAxMCBvZiBhIG51bWJlciBpbiBzY2llbnRpZmljIG5vdGF0aW9u">↗️</a><pre> <span class='Function'>⋆</span><span class='Modifier'>⁼</span> <span class='Number'>10</span>
2.302585092994046
+
<span class='Number'>2</span> <span class='Function'>⋆</span><span class='Modifier'>⁼</span> <span class='Number'>32</span> <span class='Comment'># Log base 2
</span>5
<span class='Number'>2</span> <span class='Function'>⋆</span> <span class='Number'>2</span> <span class='Function'>⋆</span><span class='Modifier'>⁼</span> <span class='Number'>32</span>
@@ -331,14 +332,14 @@
<span class='Number'>10</span> <span class='Function'>⋆</span><span class='Modifier'>⁼</span> <span class='Number'>1e4</span> <span class='Comment'># Log base 10 of a number in scientific notation
</span>4
</pre>
-<p>Another 1-modifier, which at the moment is tremendously useless, is Constant <code><span class='Modifier'>˙</span></code>. It turns its operand into a constant function that always returns the operand (inputs to modifiers are called <em>operands</em> because <em>modificands</em> is just too horrible).</p>
+<p>Another 1-modifier, which at the moment is tremendously useless, is Constant (<code><span class='Modifier'>˙</span></code>). It turns its operand into a constant function that always returns the operand (inputs to modifiers are called <em>operands</em> because <em>modificands</em> is just too horrible).</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiAzy5kgNA==">↗️</a><pre> <span class='Number'>2</span> <span class='Number'>3</span><span class='Modifier'>˙</span> <span class='Number'>4</span>
3
</pre>
<p>Well, I guess it's not pedagogically useless, as it does demonstrate that a modifier can be applied to subjects as well as functions. Even though <code><span class='Number'>3</span></code> is a subject, <code><span class='Number'>3</span><span class='Modifier'>˙</span></code> is a function, and can be applied to and ignore the two arguments <code><span class='Number'>2</span></code> and <code><span class='Number'>4</span></code>.</p>
<p>With three examples you may have noticed that 1-modifiers tend to cluster at the top of the line. In fact, every primitive 1-modifer is a superscript character: we've covered <code><span class='Modifier'>˜⁼˙</span></code>, and the remaining array-based modifiers <code><span class='Modifier'>˘¨⌜´˝`</span></code> will show up later.</p>
<h2 id="2-modifiers"><a class="header" href="#2-modifiers">2-modifiers</a></h2>
-<p>Made it to the last role, the 2-modifier (if you think something's been skipped, you're free to call subjects 0-modifiers. They don't modify anything. Just not when other people can hear you). To introduce them we'll use Atop <code><span class='Modifier2'>∘</span></code>, which composes two functions as in mathematics. The resulting function allows one or two arguments like any BQN function: these are all passed to the function on the right, and the result of that application is passed to the function on the left. So the function on the left is only ever called with one argument.</p>
+<p>Made it to the last role, the 2-modifier (if you think something's been skipped, you're free to call subjects 0-modifiers. They don't modify anything. Just not when other people can hear you). To introduce them we'll use Atop (<code><span class='Modifier2'>∘</span></code>), which composes two functions as in mathematics. The resulting function allows one or two arguments like any BQN function: these are all passed to the function on the right, and the result of that application is passed to the function on the left. So the function on the left is only ever called with one argument.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MyDDl8uc4oiYKyA0ICAjIFNxdWFyZSBvZiAzIHBsdXMgNAot4oiYKMOXy5wpIDUgICMgTmVnYXRpdmUgc3F1YXJlIG9mIDU=">↗️</a><pre> <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> <span class='Comment'># Square of 3 plus 4
</span>49
<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='Number'>5</span> <span class='Comment'># Negative square of 5
@@ -387,8 +388,8 @@
</svg>
<p>This ordering is more consistent with the rule that a 1-modifier's operand should go to its left. If we tried going from right to left we'd end up with <code><span class='Function'>×</span><span class='Paren'>(</span><span class='Modifier'>˜</span><span class='Modifier2'>∘</span><span class='Function'>+</span><span class='Paren'>)</span></code>, which uses <code><span class='Modifier'>˜</span></code> as an operand to <code><span class='Modifier2'>∘</span></code>. But a modifier can't be used as an operand. To make it work we'd have to give 1-modifiers a higher precedence than 2-modifiers.</p>
-<p>In fact, the rules for modifiers are exactly the same as those for functions, but reversed. So why is there a distinction between 1- and 2-modifiers, when for functions we can look to the left to see whether there is a left argument? The reason is that it's natural to follow a 1-modifier by a subject or function that isn't supposed to be its operand. Using an example from the last section, <code><span class='Function'>+</span><span class='Modifier'>˜</span> <span class='Number'>3</span></code> has a subject to the right of the 1-modifier <code><span class='Modifier'>˜</span></code>. Even worse, <code><span class='Function'>+</span><span class='Modifier'>˜</span> <span class='Function'>÷</span> <span class='Number'>3</span></code> looks just like <code><span class='Function'>+</span><span class='Modifier2'>∘</span> <span class='Function'>÷</span> <span class='Number'>3</span></code>, but it's two functions <code><span class='Function'>+</span><span class='Modifier'>˜</span></code> and <code><span class='Function'>÷</span></code> applied to <code><span class='Number'>3</span></code> while the version with Atop is a single function <code><span class='Function'>+</span><span class='Modifier2'>∘</span><span class='Function'>÷</span></code> applied to <code><span class='Number'>3</span></code>. So the two-layer system of functions and modifiers forces modifiers to have a fixed number of operands even though every function (including those derived by applying modifiers) can be called with one or two arguments.</p>
-<p>Remember that 1-modifiers are all superscripts? The characters for 2-modifiers use a different rule: each contains an <em>unbroken</em> circle (that is, lines might touch it but not go through it). The 2-modifiers in BQN are the combinators <code><span class='Modifier2'>∘○⊸⟜⊘</span></code>, the sort-of-combinators <code><span class='Modifier2'>⌾◶⍟</span></code>, and the not-at-all-combinators <code><span class='Modifier2'>⎉⚇⎊</span></code>. And the functions that make that unbroken circle rule necessary are written <code><span class='Function'>⌽⍉</span></code>. Since every primitive is a function, 1-modifier, or 2-modifier, you can always tell what type (and role) it has: a superscript is a 1-modifier, an unbroken circle makes it a 2-modifier, and otherwise it's a function.</p>
+<p>In fact, the rules for modifiers are exactly the same as those for functions, but reversed. So why is there a distinction between 1- and 2-modifiers, when for functions we can look to the left to see whether there's a left argument? The reason is that it's natural to follow a 1-modifier by a subject or function that isn't supposed to be its operand. Using an example from the last section, <code><span class='Function'>+</span><span class='Modifier'>˜</span> <span class='Number'>3</span></code> has a subject to the right of the 1-modifier <code><span class='Modifier'>˜</span></code>. Even worse, <code><span class='Function'>+</span><span class='Modifier'>˜</span> <span class='Function'>÷</span> <span class='Number'>3</span></code> looks just like <code><span class='Function'>+</span><span class='Modifier2'>∘</span> <span class='Function'>÷</span> <span class='Number'>3</span></code>, but it's two functions <code><span class='Function'>+</span><span class='Modifier'>˜</span></code> and <code><span class='Function'>÷</span></code> applied to <code><span class='Number'>3</span></code> while the version with Atop is a single function <code><span class='Function'>+</span><span class='Modifier2'>∘</span><span class='Function'>÷</span></code> applied to <code><span class='Number'>3</span></code>. So the two-layer system of functions and modifiers forces modifiers to have a fixed number of operands even though every function (including those derived by applying modifiers) can be called with one or two arguments.</p>
+<p>Remember how 1-modifiers are all superscripts? The characters for 2-modifiers use a different rule: each contains an <em>unbroken</em> circle (that is, lines might touch it but not go through it). The 2-modifiers in BQN are the combinators <code><span class='Modifier2'>∘○⊸⟜⊘</span></code>, the sort-of-combinators <code><span class='Modifier2'>⌾◶⍟</span></code>, and the not-at-all-combinators <code><span class='Modifier2'>⎉⚇⎊</span></code>. And the functions that make that &quot;unbroken&quot; part necessary are written <code><span class='Function'>⌽⍉</span></code>. Since every primitive is a function, 1-modifier, or 2-modifier, you can always tell what type (and role) it has: a superscript is a 1-modifier, an unbroken circle makes it a 2-modifier, and otherwise it's a function.</p>
<h2 id="summary"><a class="header" href="#summary">Summary</a></h2>
<p>The objects we've seen so far are:</p>
<table>
diff --git a/docs/tutorial/list.html b/docs/tutorial/list.html
index 6b423da0..2d0e9be9 100644
--- a/docs/tutorial/list.html
+++ b/docs/tutorial/list.html
@@ -73,7 +73,7 @@
</tr>
</table>
-<p>Finally, <em>strand notation</em> is a shortcut for simple lists, like one that just lists a few numbers. It's written with the <em>ligature</em> <code><span class='Ligature'>‿</span></code>, which has a higher precedence than either functions or operators (and on the BQN keyboard, the ligature is written with a backslash, then a space). A sequence of values joined with ligatures becomes a list, so that for example the following two expressions are equivalent:</p>
+<p>Finally, <em>strand notation</em> is a shortcut for simple lists, like one that just lists a few numbers. It's written with the <em>ligature</em> <code><span class='Ligature'>‿</span></code>, which has a higher precedence than either functions or operators (and is typed with backslash-space on the BQN keyboard). A sequence of values joined with ligatures becomes a list, so that for example the following two expressions are equivalent:</p>
<pre><span class='Bracket'>⟨</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Function'>+</span><span class='Separator'>,</span><span class='Function'>-</span><span class='Bracket'>⟩</span>
<span class='Number'>2</span><span class='Ligature'>‿</span><span class='Function'>+</span><span class='Ligature'>‿</span><span class='Function'>-</span>
</pre>
@@ -113,7 +113,7 @@
</g>
</svg>
-<p>Lists are just one-dimensional arrays. Types are divided into <em>data types</em>, which tend to have a subject role, and <em>operation types</em>, which tend to have a role matching their type. Also, any value that's not an array, such as everything we used in the last tutorial, is called an <em>atom</em>.</p>
+<p>Lists are just one-dimensional arrays. These types are divided into <em>data types</em>, which correspond to a subject role, and <em>operation types</em>, which each have a matching role. Also, any value that's not an array, such as everything we used in the last tutorial, is called an <em>atom</em>.</p>
<h2 id="arithmetic-on-lists"><a class="header" href="#arithmetic-on-lists">Arithmetic on lists</a></h2>
<p>Arithmetic functions automatically apply to each element of a list argument. If both arguments are lists, they have to have the same length, and they're matched up one element at a time.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=w7cg4p+oMiwzLDTin6kKCiJBUEwiICsgMQoKIjMxNDE1IiAtICcwJwoKNOKAvzPigL8y4oC/MSDii4YgMeKAvzLigL8z4oC/NA==">↗️</a><pre> <span class='Function'>÷</span> <span class='Bracket'>⟨</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>3</span><span class='Separator'>,</span><span class='Number'>4</span><span class='Bracket'>⟩</span>
@@ -181,8 +181,9 @@
"reward"
</pre>
<p>With a left argument <code><span class='Function'>⌽</span></code> means Rotate instead, and shifts values over by the specified amount, wrapping those that go off the end to the other side. A positive value rotates to the left, and a negative one rotates right.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDijL0g4p+oMCwxLDIsMyw04p+pCsKvMSDijL0gImJjZGVhIg==">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>⌽</span> <span class='Bracket'>⟨</span><span class='Number'>0</span><span class='Separator'>,</span><span class='Number'>1</span><span class='Separator'>,</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>3</span><span class='Separator'>,</span><span class='Number'>4</span><span class='Bracket'>⟩</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDijL0g4p+oMCwxLDIsMyw04p+pCgrCrzEg4oy9ICJiY2RlYSI=">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>⌽</span> <span class='Bracket'>⟨</span><span class='Number'>0</span><span class='Separator'>,</span><span class='Number'>1</span><span class='Separator'>,</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>3</span><span class='Separator'>,</span><span class='Number'>4</span><span class='Bracket'>⟩</span>
⟨ 2 3 4 0 1 ⟩
+
<span class='Number'>¯1</span> <span class='Function'>⌽</span> <span class='String'>&quot;bcdea&quot;</span>
"abcde"
</pre>
@@ -206,7 +207,7 @@
</tr>
</table>
-<p>The 1-modifier Each (<code><span class='Modifier'>¨</span></code>) applies its operand to every element of a list argument: it's the same as <code><span class='Value'>map</span></code> in a functional programming language. With two list arguments (which have to have the same length), Each pairs the corresponding elements from each, a bit like a <code><span class='Value'>zip</span></code> function. If one argument is a list and one's an atom, the atom is reused every time instead.</p>
+<p>The 1-modifier Each (<code><span class='Modifier'>¨</span></code>) applies its operand to every element of a list argument, like <code><span class='Value'>map</span></code> in a functional programming language. With two list arguments, Each pairs the corresponding elements like arithmetic does, or a bit like a <code><span class='Value'>zip</span></code> function (unlike arithmetic, it only goes one level deep). If one argument is a list and one's an atom, the atom is reused every time instead.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oy9wqggImFiY2Qi4oC/IkFCQ0RFRiLigL8iMDEiCgoic3RyaW5nIuKAvyJsaXN0IuKAvyJhcnJheSIg4oi+wqggJ3MnCgoiYWJjIiDii4jCqCDijL0gImFiYyI=">↗️</a><pre> <span class='Function'>⌽</span><span class='Modifier'>¨</span> <span class='String'>&quot;abcd&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;ABCDEF&quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;01&quot;</span>
⟨ "dcba" "FEDCBA" "10" ⟩
@@ -229,7 +230,7 @@
3
</pre>
<p>With this evaluation order, <code><span class='Function'>-</span><span class='Modifier'>´</span></code> gives the <em>alternating sum</em> of its argument. Think of it this way: the left argument of each <code><span class='Function'>-</span></code> is a single number, while the right argument is made up of all the numbers to the right subtracted together. So each <code><span class='Function'>-</span></code> flips the sign of every number to its right, and every number is negated by all the <code><span class='Function'>-</span></code>s to its left. The first number (<code><span class='Number'>1</span></code> above) never gets negated, the second is negated once, the third is negated twice, returning it to its original value… the signs alternate.</p>
-<p><em>Hey, isn't it dissonant that the first, second, and third numbers are negated zero, one, and two times? If they were the zeroth, first, and second it wouldn't be…</em></p>
+<p><em>Hey, isn't it dissonant that the first, second, and third numbers are negated zero, one, and two times? Not if you call them the zeroth, first, and second…</em></p>
<p>You can fold with the Join To function to join several lists together:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oi+wrQg4p+oICJjb24iLCAiY2F0IiwgImVuYXQiLCAiZSIg4p+p">↗️</a><pre> <span class='Function'>∾</span><span class='Modifier'>´</span> <span class='Bracket'>⟨</span> <span class='String'>&quot;con&quot;</span><span class='Separator'>,</span> <span class='String'>&quot;cat&quot;</span><span class='Separator'>,</span> <span class='String'>&quot;enat&quot;</span><span class='Separator'>,</span> <span class='String'>&quot;e&quot;</span> <span class='Bracket'>⟩</span>
"concatenate"
@@ -239,7 +240,7 @@
"concatenate"
</pre>
<h2 id="example-base-decoding"><a class="header" href="#example-base-decoding">Example: base decoding</a></h2>
-<p>Some people like to imagine that robots or other techno-beings speak entirely in binary-encoded ASCII, like for instance &quot;01001110 01100101 01110010 01100100 00100001&quot;. This is dumb for a lot of reasons, and the encoded text probably just says something inane, but you're a slave to curiosity and can't ignore it. Are one and a half tutorials of BQN enough to clear your conscience?</p>
+<p>Some people like to imagine that robots or other techno-beings speak entirely in binary-encoded ASCII, like for instance &quot;01001110 01100101 01110010 01100100 00100001&quot;. This is dumb for a lot of reasons, and the encoded text probably just says something inane, but you're a slave to curiosity and can't ignore it. Are one and two-thirds tutorials of BQN enough to clear your conscience?</p>
<table class='primitives'>
<tr>
<td><span class='Function'>↕</span></td>
@@ -259,7 +260,7 @@
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oaVIDg=">↗️</a><pre> <span class='Function'>↕</span> <span class='Number'>8</span>
⟨ 0 1 2 3 4 5 6 7 ⟩
</pre>
-<p>Natural numbers in BQN start at 0. I'll get to the second function in a moment, but first let's consider how we'd decode just one number in binary. I'll pick a smaller one: 9 is 1001 in binary. Like the first 1 in decimal 1001 counts for one thousand or <code><span class='Number'>10</span><span class='Function'>⋆</span><span class='Number'>3</span></code>, the first one in binary 1001 counts for 8, which is <code><span class='Number'>2</span><span class='Function'>⋆</span><span class='Number'>3</span></code>. We can put each number next to its place value like this:</p>
+<p>Natural numbers in BQN start at 0. I'll get to the second primitive in a moment, but first let's consider how we'd decode just one number in binary. I'll pick a smaller one: 9 is 1001 in binary. Like the first 1 in decimal 1001 counts for one thousand or <code><span class='Number'>10</span><span class='Function'>⋆</span><span class='Number'>3</span></code>, the first one in binary 1001 counts for 8, which is <code><span class='Number'>2</span><span class='Function'>⋆</span><span class='Number'>3</span></code>. We can put each number next to its place value like this:</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=OOKAvzTigL8y4oC/MSDii4jCqCAx4oC/MOKAvzDigL8x">↗️</a><pre> <span class='Number'>8</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>1</span> <span class='Function'>⋈</span><span class='Modifier'>¨</span> <span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span>
⟨ ⟨ 8 1 ⟩ ⟨ 4 0 ⟩ ⟨ 2 0 ⟩ ⟨ 1 1 ⟩ ⟩
</pre>
@@ -363,7 +364,7 @@
9
</pre>
<h2 id="summary"><a class="header" href="#summary">Summary</a></h2>
-<p>There are three types of syntax that create lists: the <code><span class='String'>&quot;string literal&quot;</span></code> for lists of characters and either enclosing angle brackets <code><span class='Bracket'>⟨⟩</span></code> with <code><span class='Separator'>,</span></code> or <code><span class='Separator'>⋄</span></code> or newline characters or connecting ligatures <code><span class='Ligature'>‿</span></code> for lists with arbitrary elements. The ligature has a higher precedence than functions or modifiers, so we should add it to our precedence table:</p>
+<p>There are three types of syntax that create lists. <code><span class='String'>&quot;string literal&quot;</span></code> gives a list of characters. For arbitrary lists, use enclosing angle brackets <code><span class='Bracket'>⟨⟩</span></code> with <code><span class='Separator'>,</span></code> or <code><span class='Separator'>⋄</span></code> or newline between elements, or just connect elements with ligatures <code><span class='Ligature'>‿</span></code>. The ligature has a higher precedence than functions or modifiers and might require parentheses, so we should add it to our precedence table:</p>
<table>
<thead>
<tr>
@@ -395,8 +396,8 @@
</tr>
</tbody>
</table>
-<p>The elements of a list can have any syntactic role; it's ignored and the list as a whole is a subject.</p>
-<p>We introduced a few new primitives. The links below go to the full documentation pages for them.</p>
+<p>The elements of a list can have any syntactic role. It's ignored and the list as a whole is a subject.</p>
+<p>We introduced a few new primitives. The links in the table go to their full documentation pages.</p>
<table>
<thead>
<tr>
@@ -438,5 +439,5 @@
</tr>
</tbody>
</table>
-<p>Additionally, we saw that the arithmetic functions work naturally on lists, automatically applying to every element of a single list argument or pairing up the elements of two list arguments.</p>
+<p>And we saw that the arithmetic functions work naturally on lists, automatically applying to every element of a single list argument or pairing up the elements of two list arguments.</p>
<p>Even this small amount of list functionality is enough to tackle some little problems. We haven't even introduced a function notation yet!</p>
diff --git a/tutorial/expression.md b/tutorial/expression.md
index e058007d..5a2d5218 100644
--- a/tutorial/expression.md
+++ b/tutorial/expression.md
@@ -69,7 +69,7 @@ For a longer example, here's an expression for the [volume of a sphere](https://
(4÷3) × π × 2⋆3
-The evaluation order is diagrammed below, with the function `⋆` on the first line evaluated first, then `×` on the next, and so on. The effect of the parentheses is that `÷` is evaluated before the leftmost `×`.
+The evaluation order is diagrammed below, with the function `⋆` at the highest level evaluated first, then `×` below it, and so on. The effect of the parentheses is that `÷` is evaluated before the leftmost `×`.
<!--GEN evalexp.bqn
DrawEval "(4÷3) × π × 2⋆3"
@@ -97,15 +97,15 @@ wh↩19⌾(¯1⊸⊑)wh
DrawEval "(√3 + 2×√2) - 1+√2"
-->
-But wait: how do we know that `√` in the expressions above uses the one-argument form? Remember that it can also take a left argument. For that matter, how do we know that `-` takes two arguments and not just one? Maybe this looks trivial right now: a good enough answer while we're only doing arithmetic is that a function is called with one argument if there is nothing to its left, or another function, and with two arguments otherwise. But it will get more complicated as we expand the syntax with expressions that can return functions and so on, so it's a good idea to discuss the foundations that will allow us to handle that complexity. In BQN, the way expressions are evaluated—the sequence of function calls and other operations—is determined by the *syntactic role* of the things it contains. A few rules of roles make sense of the syntax seen so far:
+But wait: how do we know that `√` in the expressions above uses the one-argument form? Remember that it can also take a left argument. For that matter, how do we know that `-` takes two arguments and not just one? Maybe this looks trivial right now: a good enough answer while we're only doing arithmetic is that a function is called with one argument if there is nothing to its left, or another function, and with two arguments otherwise. But it'll get more complicated as we expand the syntax with expressions that can return functions and so on, so it's a good idea to discuss the foundations that will allow us to handle that complexity. In BQN, the way expressions are evaluated—the sequence of function calls and other operations—is determined by the *syntactic role* of the things it contains. A few rules of roles make sense of the syntax seen so far:
* *Numeric literals* such as `1` and `π` are *subjects*.
* *Primitive functions* are *functions* (gasp).
-* A function's arguments are subjects. To call a function it must have a subject on the right, and may have a subject on the left, which is used as the left argument.
+* A function's arguments are subjects. To call a function it must have a subject on the right, and may have a subject on the left, which becomes the left argument.
* A function's result is a subject—or, more precisely, a function call expression is a subject.
* A set of parentheses has the same role as whatever's inside it.
-Perhaps more than you thought! To really get roles, it's important to understand that a role is properly a property of an expression, and not its value. In language implementation terms, roles are used only to parse expressions, giving a syntax tree, but don't dictate what values are possible when the tree is evaluated. So it's possible to have a function with a number role or a number with a function role. The reason this doesn't happen with the numeric literals and primitives we've introduced is that these tokens have a constant value. `×` or `∞` have the same value in any possible program, and so it makes sense that their types and roles should correspond. When we introduce identifiers, we'll see this correspondence break down—and why that's good!
+Perhaps more than you thought! To really get roles, it's important to understand that a role is properly a property of an expression, and not its value. In language implementation terms, roles are used only to parse expressions, giving a syntax tree, but don't dictate what values may appear when the tree is evaluated. So it's possible to have a function with a number role or a number with a function role. The reason this doesn't happen with the numeric literals and primitives we've introduced is that these tokens have a constant value. `×` or `∞` have the same value in any possible program, and so it makes sense that their types and roles should correspond. When we introduce identifiers, we'll see this correspondence break down—and why that's good!
## Character arithmetic
@@ -113,7 +113,7 @@ Gosh, that's a lot of arithmetic up there. Maybe adding characters will mix thin
'c'
-A character is written with single quotes. As in the C language, it's not the same as a string, which is written with double quotes. There are no escapes for characters: any source code character between single quotes becomes a character literal, even a newline. Some kinds of arithmetic e[x](https://xkcd.com/1537/)tend to characters:
+A character is written with single quotes. As in the C language, it's not the same as a string, which is written with double quotes. There are no character escapes: any source code character between single quotes becomes a character literal, even a newline. Some kinds of arithmetic e[x](https://xkcd.com/1537/)tend to characters:
'c' + 1
'h' - 'a'
@@ -149,7 +149,7 @@ Addition and subtraction with affine characters have all the same algebraic prop
## Modifiers
-Functions are nice and all, but to really bring us into the space age BQN has a second level of function called *modifiers* (the space age in this case is when operators were introduced to APL in the early 60s—hey, did you know the [second APL conference](https://aplwiki.com/wiki/APL_conference#1970) was held at Goddard Space Flight Center?). While functions apply to subjects, modifiers can apply to functions *or* subjects, and return functions. For example, the 1-modifier `˜` modifies one function—that's where the 1 comes from—by swapping the arguments before calling it (Swap), or copying the right argument to the left if there's only one (Self).
+Functions are nice and all, but to really bring us into the space age BQN has a second level of function called *modifiers* (the space age in this case is when operators were introduced to APL in the early 60s—hey, did you know the [second APL conference](https://aplwiki.com/wiki/APL_conference#1970) was held at Goddard Space Flight Center?). While functions apply to subjects, modifiers apply to functions *or* subjects, and return functions. For example, the 1-modifier `˜` modifies one function—that's where the 1 comes from—by swapping the arguments before calling it (Swap), or copying the right argument to the left if there's only one (Self).
2 -˜ 'd' # Subtract from
+˜ 3 # Add to itself
@@ -164,18 +164,19 @@ What's wrong with `4⋆2`? Depends on the context. Because of the way evaluation
<!--GEN
Primitives ⟨"˜%`%Swap%Self", "⁼%3%Undo", "˙%""%Constant"⟩
-->
-Another 1-modifier is Undo (`⁼`). BQN has just enough computer algebra facilities to look like a tool for Neanderthals next to a real computer algebra system, and among them is the ability to invert some primitives. In general you can't be sure when Undo will work (it might even be undecidable), but the examples I'll give here are guaranteed by [the spec](../spec/inferred.md#undo) to always work in the same way. Starting with a *third* way to square a number:
+Another 1-modifier is Undo (`⁼`). BQN has just enough computer algebra facilities to look like a tool for Neanderthals next to a real computer algebra system, and among them is the ability to invert some primitives. Undo has a [specification](../spec/inferred.md#undo) that fixes results for some functions and modifiers, but allows implementations to go further. In the tutorials we'll stick to the required stuff, which is definitely enough to be practically useful. Starting with a *third* way to square a number:
√⁼ 4
But the most important use for Undo in arithmetic is the logarithm, written `⋆⁼`. That's all a logarithm is: it undoes the Power function! With no left argument `⋆⁼` is the natural logarithm. If there's a left argument then Undo considers it part of the function to be undone. The result in this case is that `⋆⁼` with two arguments is the logarithm of the right argument with base given by the left one.
⋆⁼ 10
+
2 ⋆⁼ 32 # Log base 2
2 ⋆ 2 ⋆⁼ 32
10 ⋆⁼ 1e4 # Log base 10 of a number in scientific notation
-Another 1-modifier, which at the moment is tremendously useless, is Constant `˙`. It turns its operand into a constant function that always returns the operand (inputs to modifiers are called *operands* because *modificands* is just too horrible).
+Another 1-modifier, which at the moment is tremendously useless, is Constant (`˙`). It turns its operand into a constant function that always returns the operand (inputs to modifiers are called *operands* because *modificands* is just too horrible).
2 3˙ 4
@@ -185,7 +186,7 @@ With three examples you may have noticed that 1-modifiers tend to cluster at the
## 2-modifiers
-Made it to the last role, the 2-modifier (if you think something's been skipped, you're free to call subjects 0-modifiers. They don't modify anything. Just not when other people can hear you). To introduce them we'll use Atop `∘`, which composes two functions as in mathematics. The resulting function allows one or two arguments like any BQN function: these are all passed to the function on the right, and the result of that application is passed to the function on the left. So the function on the left is only ever called with one argument.
+Made it to the last role, the 2-modifier (if you think something's been skipped, you're free to call subjects 0-modifiers. They don't modify anything. Just not when other people can hear you). To introduce them we'll use Atop (`∘`), which composes two functions as in mathematics. The resulting function allows one or two arguments like any BQN function: these are all passed to the function on the right, and the result of that application is passed to the function on the left. So the function on the left is only ever called with one argument.
3 ט∘+ 4 # Square of 3 plus 4
-∘(ט) 5 # Negative square of 5
@@ -203,9 +204,9 @@ DrawEval "3 ט∘+ 4"
This ordering is more consistent with the rule that a 1-modifier's operand should go to its left. If we tried going from right to left we'd end up with `×(˜∘+)`, which uses `˜` as an operand to `∘`. But a modifier can't be used as an operand. To make it work we'd have to give 1-modifiers a higher precedence than 2-modifiers.
-In fact, the rules for modifiers are exactly the same as those for functions, but reversed. So why is there a distinction between 1- and 2-modifiers, when for functions we can look to the left to see whether there is a left argument? The reason is that it's natural to follow a 1-modifier by a subject or function that isn't supposed to be its operand. Using an example from the last section, `+˜ 3` has a subject to the right of the 1-modifier `˜`. Even worse, `+˜ ÷ 3` looks just like `+∘ ÷ 3`, but it's two functions `+˜` and `÷` applied to `3` while the version with Atop is a single function `+∘÷` applied to `3`. So the two-layer system of functions and modifiers forces modifiers to have a fixed number of operands even though every function (including those derived by applying modifiers) can be called with one or two arguments.
+In fact, the rules for modifiers are exactly the same as those for functions, but reversed. So why is there a distinction between 1- and 2-modifiers, when for functions we can look to the left to see whether there's a left argument? The reason is that it's natural to follow a 1-modifier by a subject or function that isn't supposed to be its operand. Using an example from the last section, `+˜ 3` has a subject to the right of the 1-modifier `˜`. Even worse, `+˜ ÷ 3` looks just like `+∘ ÷ 3`, but it's two functions `+˜` and `÷` applied to `3` while the version with Atop is a single function `+∘÷` applied to `3`. So the two-layer system of functions and modifiers forces modifiers to have a fixed number of operands even though every function (including those derived by applying modifiers) can be called with one or two arguments.
-Remember that 1-modifiers are all superscripts? The characters for 2-modifiers use a different rule: each contains an *unbroken* circle (that is, lines might touch it but not go through it). The 2-modifiers in BQN are the combinators `∘○⊸⟜⊘`, the sort-of-combinators `⌾◶⍟`, and the not-at-all-combinators `⎉⚇⎊`. And the functions that make that unbroken circle rule necessary are written `⌽⍉`. Since every primitive is a function, 1-modifier, or 2-modifier, you can always tell what type (and role) it has: a superscript is a 1-modifier, an unbroken circle makes it a 2-modifier, and otherwise it's a function.
+Remember how 1-modifiers are all superscripts? The characters for 2-modifiers use a different rule: each contains an *unbroken* circle (that is, lines might touch it but not go through it). The 2-modifiers in BQN are the combinators `∘○⊸⟜⊘`, the sort-of-combinators `⌾◶⍟`, and the not-at-all-combinators `⎉⚇⎊`. And the functions that make that "unbroken" part necessary are written `⌽⍉`. Since every primitive is a function, 1-modifier, or 2-modifier, you can always tell what type (and role) it has: a superscript is a 1-modifier, an unbroken circle makes it a 2-modifier, and otherwise it's a function.
## Summary
diff --git a/tutorial/list.md b/tutorial/list.md
index bd8071a6..b34587ca 100644
--- a/tutorial/list.md
+++ b/tutorial/list.md
@@ -41,7 +41,7 @@ The two characters `,` and `⋄` are completely interchangeable, and newline is
<!--GEN
Primitives ⟨"#%%Comment", "‿% %Strand"⟩
-->
-Finally, *strand notation* is a shortcut for simple lists, like one that just lists a few numbers. It's written with the *ligature* `‿`, which has a higher precedence than either functions or operators (and on the BQN keyboard, the ligature is written with a backslash, then a space). A sequence of values joined with ligatures becomes a list, so that for example the following two expressions are equivalent:
+Finally, *strand notation* is a shortcut for simple lists, like one that just lists a few numbers. It's written with the *ligature* `‿`, which has a higher precedence than either functions or operators (and is typed with backslash-space on the BQN keyboard). A sequence of values joined with ligatures becomes a list, so that for example the following two expressions are equivalent:
⟨2,+,-⟩
2‿+‿-
@@ -90,7 +90,7 @@ FS ← {𝕩 Enc˜ "g"Attr⟨"font-size",(Fmt𝕨)∾"px"⟩}
-->
-Lists are just one-dimensional arrays. Types are divided into *data types*, which tend to have a subject role, and *operation types*, which tend to have a role matching their type. Also, any value that's not an array, such as everything we used in the last tutorial, is called an *atom*.
+Lists are just one-dimensional arrays. These types are divided into *data types*, which correspond to a subject role, and *operation types*, which each have a matching role. Also, any value that's not an array, such as everything we used in the last tutorial, is called an *atom*.
## Arithmetic on lists
@@ -140,6 +140,7 @@ Reverse (`⌽`) puts the list back to front.
With a left argument `⌽` means Rotate instead, and shifts values over by the specified amount, wrapping those that go off the end to the other side. A positive value rotates to the left, and a negative one rotates right.
2 ⌽ ⟨0,1,2,3,4⟩
+
¯1 ⌽ "bcdea"
### …and modifiers
@@ -147,7 +148,7 @@ With a left argument `⌽` means Rotate instead, and shifts values over by the s
<!--GEN
Primitives ⟨"¨%2%Each", "´%5%Fold", "∾%,%Join%Join To"⟩
-->
-The 1-modifier Each (`¨`) applies its operand to every element of a list argument: it's the same as `map` in a functional programming language. With two list arguments (which have to have the same length), Each pairs the corresponding elements from each, a bit like a `zip` function. If one argument is a list and one's an atom, the atom is reused every time instead.
+The 1-modifier Each (`¨`) applies its operand to every element of a list argument, like `map` in a functional programming language. With two list arguments, Each pairs the corresponding elements like arithmetic does, or a bit like a `zip` function (unlike arithmetic, it only goes one level deep). If one argument is a list and one's an atom, the atom is reused every time instead.
⌽¨ "abcd"‿"ABCDEF"‿"01"
@@ -167,7 +168,7 @@ To match the order of BQN evaluation, Fold moves over its argument array from ri
With this evaluation order, `-´` gives the *alternating sum* of its argument. Think of it this way: the left argument of each `-` is a single number, while the right argument is made up of all the numbers to the right subtracted together. So each `-` flips the sign of every number to its right, and every number is negated by all the `-`s to its left. The first number (`1` above) never gets negated, the second is negated once, the third is negated twice, returning it to its original value… the signs alternate.
-*Hey, isn't it dissonant that the first, second, and third numbers are negated zero, one, and two times? If they were the zeroth, first, and second it wouldn't be…*
+*Hey, isn't it dissonant that the first, second, and third numbers are negated zero, one, and two times? Not if you call them the zeroth, first, and second…*
You can fold with the Join To function to join several lists together:
@@ -179,7 +180,7 @@ But you shouldn't! Just `∾` will do the job for you—with no left argument it
## Example: base decoding
-Some people like to imagine that robots or other techno-beings speak entirely in binary-encoded ASCII, like for instance "01001110 01100101 01110010 01100100 00100001". This is dumb for a lot of reasons, and the encoded text probably just says something inane, but you're a slave to curiosity and can't ignore it. Are one and a half tutorials of BQN enough to clear your conscience?
+Some people like to imagine that robots or other techno-beings speak entirely in binary-encoded ASCII, like for instance "01001110 01100101 01110010 01100100 00100001". This is dumb for a lot of reasons, and the encoded text probably just says something inane, but you're a slave to curiosity and can't ignore it. Are one and two-thirds tutorials of BQN enough to clear your conscience?
<!--GEN
Primitives ⟨"↕%d%Range%", "⊸%h%Bind?%"⟩
@@ -188,7 +189,7 @@ Almost. It's really close. There are just two things missing, so I'll cover thos
↕ 8
-Natural numbers in BQN start at 0. I'll get to the second function in a moment, but first let's consider how we'd decode just one number in binary. I'll pick a smaller one: 9 is 1001 in binary. Like the first 1 in decimal 1001 counts for one thousand or `10⋆3`, the first one in binary 1001 counts for 8, which is `2⋆3`. We can put each number next to its place value like this:
+Natural numbers in BQN start at 0. I'll get to the second primitive in a moment, but first let's consider how we'd decode just one number in binary. I'll pick a smaller one: 9 is 1001 in binary. Like the first 1 in decimal 1001 counts for one thousand or `10⋆3`, the first one in binary 1001 counts for 8, which is `2⋆3`. We can put each number next to its place value like this:
8‿4‿2‿1 ⋈¨ 1‿0‿0‿1
@@ -248,7 +249,7 @@ Was it as anticlimactic as you'd hoped? In fact there's a simpler way to do the
## Summary
-There are three types of syntax that create lists: the `"string literal"` for lists of characters and either enclosing angle brackets `⟨⟩` with `,` or `⋄` or newline characters or connecting ligatures `‿` for lists with arbitrary elements. The ligature has a higher precedence than functions or modifiers, so we should add it to our precedence table:
+There are three types of syntax that create lists. `"string literal"` gives a list of characters. For arbitrary lists, use enclosing angle brackets `⟨⟩` with `,` or `⋄` or newline between elements, or just connect elements with ligatures `‿`. The ligature has a higher precedence than functions or modifiers and might require parentheses, so we should add it to our precedence table:
Precedence | Role | Associativity
-----------|----------|--------------
@@ -257,9 +258,9 @@ Precedence | Role | Associativity
2 | Modifier | Left-to-right
3 | Function | Right-to-left
-The elements of a list can have any syntactic role; it's ignored and the list as a whole is a subject.
+The elements of a list can have any syntactic role. It's ignored and the list as a whole is a subject.
-We introduced a few new primitives. The links below go to the full documentation pages for them.
+We introduced a few new primitives. The links in the table go to their full documentation pages.
Glyph | 1 arg | 2 args
------|------------------------------|--------
@@ -270,6 +271,6 @@ Glyph | 1 arg | 2 args
`¨` | [Each](../doc/map.md) | [Each](../doc/map.md#each)
`´` | [Fold](../doc/fold.md#fold)
-Additionally, we saw that the arithmetic functions work naturally on lists, automatically applying to every element of a single list argument or pairing up the elements of two list arguments.
+And we saw that the arithmetic functions work naturally on lists, automatically applying to every element of a single list argument or pairing up the elements of two list arguments.
Even this small amount of list functionality is enough to tackle some little problems. We haven't even introduced a function notation yet!