aboutsummaryrefslogtreecommitdiff
path: root/docs/doc/quick.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doc/quick.html')
-rw-r--r--docs/doc/quick.html20
1 files changed, 10 insertions, 10 deletions
diff --git a/docs/doc/quick.html b/docs/doc/quick.html
index 3b89af8c..af70a7b7 100644
--- a/docs/doc/quick.html
+++ b/docs/doc/quick.html
@@ -62,7 +62,7 @@
<p>The function <code><span class='Function'>Lower</span></code> is defined to be <code><span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Value'>diff</span></code>, but it uses a different arrow <code><span class='Gets'>⇐</span></code> to do this. This is an <a href="namespace.html#exports">export</a>, and it declares that <code><span class='Function'>Lower</span></code> is a <em>field</em> of a namespace that can be accessed from the outside. Having a <code><span class='Gets'>⇐</span></code> in it is also what makes the block define a namespace. <code><span class='Function'>Lower</span></code> itself won't be used for a while, but <code><span class='Function'>Upper</span></code> is accessed a few lines down, with <code><span class='Value'>case.</span><span class='Function'>Upper</span></code>.</p>
<p><code><span class='Function'>Lower</span></code> is created with a modifier again, this time the 2-modifier <code><span class='Modifier2'>⟜</span></code>. We've now seen one each of the three <a href="primitive.html"><em>primitive</em></a> types: function, 1-modifier, and 2-modifier. There are a lot of primitives, but some simple rules tell you which type they have. Primitives are functions by default, but superscript characters are 1-modifiers (<code><span class='Modifier'>´⁼˘¨˜`</span></code> in our program), and ones with an unbroken circle are 2-modifiers (<code><span class='Modifier2'>⟜∘⌾</span></code>; <code><span class='Function'>⍉</span></code> is a broken circle so it's a function). Variable names follow a <a href="expression.html#role-spellings">similar system</a>, where functions start with an uppercase letter and subjects with a lowercase one.</p>
<p><a href="hook.html">After</a> (<code><span class='Modifier2'>⟜</span></code>) takes two operands, <code><span class='Function'>-</span></code> and <code><span class='Value'>diff</span></code>, to produce a function—specifically, it binds <code><span class='Value'>diff</span></code> as the right argument of <code><span class='Function'>-</span></code>, so that calling it on an argument subtracts <code><span class='Value'>diff</span></code> from that argument.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=LeKfnGRpZmYgJ0cnCgonRycgLSBkaWZm">↗️</a><pre> <span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Value'>diff</span> <span class='String'>'G'</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ZGlmZiDihpAgLcK0ICJBYSIKLeKfnGRpZmYgJ0cnCgonRycgLSBkaWZm">↗️</a><pre> <span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Value'>diff</span> <span class='String'>'G'</span>
'g'
<span class='String'>'G'</span> <span class='Function'>-</span> <span class='Value'>diff</span>
@@ -147,7 +147,7 @@
</span>⟨ "Hello" "World" ⟩
</pre>
<p>That converts the first character of each string to uppercase! <code><span class='Value'>case.</span><span class='Function'>Upper</span></code> is the case conversion function defined before, so that part makes sense. The rest of the function, <code><span class='Modifier2'>⌾</span><span class='Paren'>(</span><span class='Function'>⊑</span><span class='Modifier'>¨</span><span class='Paren'>)</span></code>, would be pronounced &quot;<a href="under.html">Under</a> the <a href="pick.html#first">First</a> of <a href="map.html#one-argument-mapping">Each</a>&quot;, which… pretty much makes sense too? The First Each function extracts the first element of each list in <code><span class='Value'>hw</span></code>, the part that used to be <code><span class='String'>&quot;hw&quot;</span></code> but is now <code><span class='String'>&quot;HW&quot;</span></code>.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqRwqggaHcKCmNhc2UuVXBwZXIgImh3Ig==">↗️</a><pre> <span class='Function'>⊑</span><span class='Modifier'>¨</span> <span class='Value'>hw</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcg4oaQIDzLmCAy4oC/4oiYIOKliiAiaGVsbG93b3JsZCIKaHcgY2FzZS5VcHBlcuKMvijiipHCqCnihqkgICMgU2V0cyBuZXcgdmFsdWUgZm9yIGh3CuKKkcKoIGh3CgpjYXNlLlVwcGVyICJodyI=">↗️</a><pre> <span class='Function'>⊑</span><span class='Modifier'>¨</span> <span class='Value'>hw</span>
"HW"
<span class='Value'>case.</span><span class='Function'>Upper</span> <span class='String'>&quot;hw&quot;</span>
@@ -163,14 +163,14 @@
<pre><span class='Function'>•Out</span> <span class='Value'>hw</span> <span class='Gets'>↩</span> <span class='Function'>∾</span> <span class='Function'>⥊⍉</span> <span class='Bracket'>[</span><span class='Value'>hw</span><span class='Separator'>,</span> <span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span><span class='Bracket'>]</span> <span class='Comment'># Hello, World!
</span></pre>
<p>None of these functions have a subject to the left, so they're all evaluated as prefix functions. But first, we have the <a href="arrayrepr.html#high-rank-arrays">array notation</a> <code><span class='Bracket'>[]</span></code>. This syntax forms an array from its major cells <code><span class='Value'>hw</span></code> and <code><span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span></code> (another strand, a list of two strings). Because the major cells are both lists, we have another rank 2 array.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=W2h3LCAiLCAi4oC/IiEiXQ==">↗️</a><pre> <span class='Bracket'>[</span><span class='Value'>hw</span><span class='Separator'>,</span> <span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span><span class='Bracket'>]</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcg4oaQIDzLmCAy4oC/4oiYIOKliiAiaGVsbG93b3JsZCIKaHcgY2FzZS5VcHBlcuKMvijiipHCqCnihqkgICMgU2V0cyBuZXcgdmFsdWUgZm9yIGh3CltodywgIiwgIuKAvyIhIl0=">↗️</a><pre> <span class='Bracket'>[</span><span class='Value'>hw</span><span class='Separator'>,</span> <span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span><span class='Bracket'>]</span>
┌─
╵ "Hello" "World"
", " "!"
</pre>
<p>The reason for forming this array is to interleave the elements, or we might say to read down the columns rather than across the rows. This ordering is done with a <a href="transpose.html">Transpose</a> to exchange the two axes, then a <a href="reshape.html#deshape">Deshape</a> to flatten it out, giving a list.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4o2JIFtodywgIiwgIuKAvyIhIl0KCuKliiDijYkgW2h3LCAiLCAi4oC/IiEiXQ==">↗️</a><pre> <span class='Function'>⍉</span> <span class='Bracket'>[</span><span class='Value'>hw</span><span class='Separator'>,</span> <span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span><span class='Bracket'>]</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcg4oaQIDzLmCAy4oC/4oiYIOKliiAiaGVsbG93b3JsZCIKaHcgY2FzZS5VcHBlcuKMvijiipHCqCnihqkgICMgU2V0cyBuZXcgdmFsdWUgZm9yIGh3CuKNiSBbaHcsICIsICLigL8iISJdCgripYog4o2JIFtodywgIiwgIuKAvyIhIl0=">↗️</a><pre> <span class='Function'>⍉</span> <span class='Bracket'>[</span><span class='Value'>hw</span><span class='Separator'>,</span> <span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span><span class='Bracket'>]</span>
┌─
╵ "Hello" ", "
"World" "!"
@@ -180,7 +180,7 @@
⟨ "Hello" ", " "World" "!" ⟩
</pre>
<p>Finally, <a href="join.html">Join</a> combines this list of strings into a single string.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcg4oapIOKIviDipYrijYkgW2h3LCAiLCAi4oC/IiEiXQpodw==">↗️</a><pre> <span class='Value'>hw</span> <span class='Gets'>↩</span> <span class='Function'>∾</span> <span class='Function'>⥊⍉</span> <span class='Bracket'>[</span><span class='Value'>hw</span><span class='Separator'>,</span> <span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span><span class='Bracket'>]</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcg4oaQIDzLmCAy4oC/4oiYIOKliiAiaGVsbG93b3JsZCIKaHcgY2FzZS5VcHBlcuKMvijiipHCqCnihqkgICMgU2V0cyBuZXcgdmFsdWUgZm9yIGh3Cmh3IOKGqSDiiL4g4qWK4o2JIFtodywgIiwgIuKAvyIhIl0KaHc=">↗️</a><pre> <span class='Value'>hw</span> <span class='Gets'>↩</span> <span class='Function'>∾</span> <span class='Function'>⥊⍉</span> <span class='Bracket'>[</span><span class='Value'>hw</span><span class='Separator'>,</span> <span class='String'>&quot;, &quot;</span><span class='Ligature'>‿</span><span class='String'>&quot;!&quot;</span><span class='Bracket'>]</span>
<span class='Value'>hw</span>
"Hello, World!"
</pre>
@@ -249,7 +249,7 @@
<span class='Paren'>(</span><span class='Function'>∾</span><span class='Modifier'>¨</span> <span class='Function'>GV</span> <span class='Function'>⊔</span><span class='Modifier'>˜</span> <span class='Nothing'>·</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Function'>GS</span><span class='Paren'>)</span> <span class='Value'>r</span>
</pre>
<p>The first line here applies <code><span class='Function'>Proc</span></code> to each character and the one before it, using <code><span class='String'>' '</span></code> as the character &quot;before&quot; the first. <code><span class='Function'>Proc</span><span class='Brace'>{</span><span class='Function'>»𝔽</span><span class='Modifier'>¨</span><span class='Function'>⊢</span><span class='Brace'>}</span> <span class='Value'>𝕩</span></code> is a fancy way to write <code><span class='Paren'>(</span><span class='Function'>»</span><span class='Value'>𝕩</span><span class='Paren'>)</span> <span class='Function'>Proc</span><span class='Modifier'>¨</span> <span class='Value'>𝕩</span></code>, which we'll explain in a moment. First, here's what the <a href="shift.html">Nudge</a> function <code><span class='Function'>»</span></code> does.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcKwrtodw==">↗️</a><pre> <span class='Value'>hw</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcg4oaQIDzLmCAy4oC/4oiYIOKliiAiaGVsbG93b3JsZCIKaHcgY2FzZS5VcHBlcuKMvijiipHCqCnihqkgICMgU2V0cyBuZXcgdmFsdWUgZm9yIGh3Cmh3IOKGqSDiiL4g4qWK4o2JIFtodywgIiwgIuKAvyIhIl0KaHcKwrtodw==">↗️</a><pre> <span class='Value'>hw</span>
"Hello, World!"
<span class='Function'>»</span><span class='Value'>hw</span>
" Hello, World"
@@ -257,7 +257,7 @@
<p>It moves its argument forward by one, adding a space character (the array's <a href="fill.html">fill</a>) but keeping the same length. This gives the previous characters that we want to use for <code><span class='Function'>Proc</span></code>'s left argument. Here <a href="map.html#each">Each</a> is used with two arguments, so that it iterates over them simultaneously, like a &quot;zip&quot; in some languages.</p>
<p>What about the fancy syntax <code><span class='Function'>Proc</span><span class='Brace'>{</span><span class='Function'>»𝔽</span><span class='Modifier'>¨</span><span class='Function'>⊢</span><span class='Brace'>}</span> <span class='Value'>𝕩</span></code>? The block <code><span class='Brace'>{</span><span class='Function'>»𝔽</span><span class='Modifier'>¨</span><span class='Function'>⊢</span><span class='Brace'>}</span></code> is an immediate 1-modifier because it uses <code><span class='Function'>𝔽</span></code> for an <a href="block.html#operands">operand</a> but not the arguments <code><span class='Value'>𝕨</span></code> or <code><span class='Value'>𝕩</span></code>. This means it acts on <code><span class='Function'>Proc</span></code> only, giving <code><span class='Function'>»Proc</span><span class='Modifier'>¨</span><span class='Function'>⊢</span></code>, which is a <a href="train.html">train</a> because it ends in a function <code><span class='Function'>⊢</span></code>. Following the rules for a 3-train, <code><span class='Paren'>(</span><span class='Function'>»Proc</span><span class='Modifier'>¨</span><span class='Function'>⊢</span><span class='Paren'>)</span><span class='Value'>𝕩</span></code> expands to <code><span class='Paren'>(</span><span class='Function'>»</span><span class='Value'>𝕩</span><span class='Paren'>)</span> <span class='Function'>Proc</span><span class='Modifier'>¨</span> <span class='Paren'>(</span><span class='Function'>⊢</span><span class='Value'>𝕩</span><span class='Paren'>)</span></code>, and since <code><span class='Function'>⊢</span></code> is the <a href="identity.html">identity function</a>, <code><span class='Function'>⊢</span><span class='Value'>𝕩</span></code> is <code><span class='Value'>𝕩</span></code>.</p>
<p>Since a display of lots of namespaces isn't too enlightening, we'll skip ahead and show what the results of <code><span class='Function'>GV</span></code> and <code><span class='Function'>GS</span></code> on those lists would be. <code><span class='Function'>GV</span></code> turns each character into a string, except it makes a space into the empty string. <code><span class='Function'>GS</span></code> has a <code><span class='Number'>1</span></code> in the places where we want to split the string.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=c3Ag4oaQICcgJz1odwpndiDihpAgKDEtc3ApIOKlisKoIGh3CmdzIOKGkCBzcCDiiKggwrviirg9IGh3CgpndgoKZ3M=">↗️</a><pre> <span class='Value'>sp</span> <span class='Gets'>←</span> <span class='String'>' '</span><span class='Function'>=</span><span class='Value'>hw</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=aHcg4oaQIDzLmCAy4oC/4oiYIOKliiAiaGVsbG93b3JsZCIKaHcgY2FzZS5VcHBlcuKMvijiipHCqCnihqkgICMgU2V0cyBuZXcgdmFsdWUgZm9yIGh3Cmh3IOKGqSDiiL4g4qWK4o2JIFtodywgIiwgIuKAvyIhIl0Kc3Ag4oaQICcgJz1odwpndiDihpAgKDEtc3ApIOKlisKoIGh3CmdzIOKGkCBzcCDiiKggwrviirg9IGh3CgpndgoKZ3M=">↗️</a><pre> <span class='Value'>sp</span> <span class='Gets'>←</span> <span class='String'>' '</span><span class='Function'>=</span><span class='Value'>hw</span>
<span class='Value'>gv</span> <span class='Gets'>←</span> <span class='Paren'>(</span><span class='Number'>1</span><span class='Function'>-</span><span class='Value'>sp</span><span class='Paren'>)</span> <span class='Function'>⥊</span><span class='Modifier'>¨</span> <span class='Value'>hw</span>
<span class='Value'>gs</span> <span class='Gets'>←</span> <span class='Value'>sp</span> <span class='Function'>∨</span> <span class='Function'>»</span><span class='Modifier2'>⊸</span><span class='Function'>=</span> <span class='Value'>hw</span>
@@ -312,18 +312,18 @@
</svg>
<p>There are actually three train groupings here: from right to left, <code><span class='Nothing'>·</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Function'>GS</span></code>, <code><span class='Function'>GV</span> <span class='Function'>⊔</span><span class='Modifier'>˜</span> <span class='Value'>…</span></code>, and <code><span class='Function'>∾</span><span class='Modifier'>¨</span> <span class='Value'>…</span></code>. Two of them are 2-trains, which apply one function to the result of another, but the one with <code><span class='Function'>⊔</span></code> is a 3-train, applying a function to two results. In the end, functions <code><span class='Function'>GS</span></code> and <code><span class='Function'>GV</span></code> are applied to <code><span class='Value'>r</span></code>. In fact, to evaluate the entire train we can replace these two functions with their results, giving <code><span class='Function'>∾</span><span class='Modifier'>¨</span> <span class='Paren'>(</span><span class='Function'>GV</span> <span class='Value'>r</span><span class='Paren'>)</span> <span class='Function'>⊔</span><span class='Modifier'>˜</span> <span class='Nothing'>·</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Paren'>(</span><span class='Function'>GS</span> <span class='Value'>r</span><span class='Paren'>)</span></code>.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oi+wqggZ3Yg4oqUy5wgwrcrYGdz">↗️</a><pre> <span class='Function'>∾</span><span class='Modifier'>¨</span> <span class='Value'>gv</span> <span class='Function'>⊔</span><span class='Modifier'>˜</span> <span class='Nothing'>·</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Value'>gs</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Z3Yg4oaQICgxLXNwKSDipYrCqCBodwpncyDihpAgc3Ag4oioIMK74oq4PSBodwriiL7CqCBndiDiipTLnCDCtytgZ3M=">↗️</a><pre> <span class='Function'>∾</span><span class='Modifier'>¨</span> <span class='Value'>gv</span> <span class='Function'>⊔</span><span class='Modifier'>˜</span> <span class='Nothing'>·</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Value'>gs</span>
⟨ "Hel" "lo," "World!" ⟩
</pre>
<p>In this expression, <a href="expression.html#nothing">Nothing</a> can be removed without changing the meaning. It's used in the train to force <code><span class='Function'>+</span><span class='Modifier'>`</span></code> to apply to <code><span class='Function'>GS</span></code> as a 2-train instead of also taking <code><span class='Function'>⊔</span><span class='Modifier'>˜</span></code> as a left argument. The <a href="scan.html">Scan</a> <code><span class='Function'>+</span><span class='Modifier'>`</span></code> is a prefix sum, progressively adding up the numbers in <code><span class='Value'>gs</span></code>.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Z3MKCitgZ3M=">↗️</a><pre> <span class='Value'>gs</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Z3Mg4oaQIHNwIOKIqCDCu+KKuD0gaHcKZ3MKCitgZ3M=">↗️</a><pre> <span class='Value'>gs</span>
⟨ 0 0 0 1 0 0 1 0 0 0 0 0 0 ⟩
<span class='Function'>+</span><span class='Modifier'>`</span><span class='Value'>gs</span>
⟨ 0 0 0 1 1 1 2 2 2 2 2 2 2 ⟩
</pre>
<p>The next bit uses <a href="swap.html">Swap</a> to switch the order: <code><span class='Value'>gv</span> <span class='Function'>⊔</span><span class='Modifier'>˜</span> <span class='Function'>+</span><span class='Modifier'>`</span><span class='Value'>gs</span></code> is <code><span class='Paren'>(</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Value'>gs</span><span class='Paren'>)</span> <span class='Function'>⊔</span> <span class='Value'>gv</span></code>, but sometimes the different order can read better (here it was mostly to squeeze Nothing into the program, I'll admit). <a href="group.html">Group</a> then splits <code><span class='Value'>gv</span></code> up based on the indices given: the first three elements become element 0 of the result, the next three element 1, and the rest element 2.</p>
-<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KCtgZ3MpIOKKlCBndg==">↗️</a><pre> <span class='Paren'>(</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Value'>gs</span><span class='Paren'>)</span> <span class='Function'>⊔</span> <span class='Value'>gv</span>
+<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Z3Yg4oaQICgxLXNwKSDipYrCqCBodwpncyDihpAgc3Ag4oioIMK74oq4PSBodwooK2Bncykg4oqUIGd2">↗️</a><pre> <span class='Paren'>(</span><span class='Function'>+</span><span class='Modifier'>`</span><span class='Value'>gs</span><span class='Paren'>)</span> <span class='Function'>⊔</span> <span class='Value'>gv</span>
┌─
· ⟨ "H" "e" "l" ⟩ ⟨ "l" "o" "," ⟩ ⟨ ⟨⟩ "W" "o" "r" "l" "d" "!" ⟩