diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-12-30 20:57:20 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2022-12-30 20:57:20 -0500 |
| commit | 8ddad454b30cdafc9bbdc0cbd51c653bee8a87e5 (patch) | |
| tree | 9c267498157b26caf82ff5e0baf9b190a5e84837 /docs/tutorial | |
| parent | 2f4f1d38f0aec449c39a15cdaaa5e160b4a78a4e (diff) | |
Rebuild with CBQN's new number formatting (ryu)
Diffstat (limited to 'docs/tutorial')
| -rw-r--r-- | docs/tutorial/combinator.html | 6 | ||||
| -rw-r--r-- | docs/tutorial/expression.html | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/docs/tutorial/combinator.html b/docs/tutorial/combinator.html index baddaa83..cba64b16 100644 --- a/docs/tutorial/combinator.html +++ b/docs/tutorial/combinator.html @@ -546,7 +546,7 @@ <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oaV4oq4w7cgOAoo4oaVOCkgw7cgNw==">↗️</a><pre> <span class='Function'>↕</span><span class='Modifier2'>⊸</span><span class='Function'>÷</span> <span class='Number'>8</span> ⟨ 0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 ⟩ <span class='Paren'>(</span><span class='Function'>↕</span><span class='Number'>8</span><span class='Paren'>)</span> <span class='Function'>÷</span> <span class='Number'>7</span> -⟨ 0 0.1428571428571428 0.2857142857142857 0.4285714285714285 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩ +⟨ 0 0.14285714285714285 0.2857142857142857 0.42857142857142855 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩ </pre> <p>What function turns 8 into 7? We can bind <code><span class='Number'>1</span></code> to <code><span class='Function'>-</span></code> on the left:</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=LeKfnDEgOA==">↗️</a><pre> <span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Number'>1</span> <span class='Number'>8</span> @@ -554,11 +554,11 @@ </pre> <p>Now we need to apply <code><span class='Function'>↕</span></code> <em>and</em> this function to <code><span class='Number'>8</span></code>, dividing the results. It turns out we can do this using both Before and After. On one side we'll have <code><span class='Function'>↕</span><span class='Number'>8</span></code>, and on the other <code><span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Number'>1</span> <span class='Number'>8</span></code>.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oaV4oq4w7fin5woLeKfnDEpIDg=">↗️</a><pre> <span class='Function'>↕</span><span class='Modifier2'>⊸</span><span class='Function'>÷</span><span class='Modifier2'>⟜</span><span class='Paren'>(</span><span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Number'>1</span><span class='Paren'>)</span> <span class='Number'>8</span> -⟨ 0 0.1428571428571428 0.2857142857142857 0.4285714285714285 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩ +⟨ 0 0.14285714285714285 0.2857142857142857 0.42857142857142855 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩ </pre> <p>This structure—Before on the left, After on the right—is also useful with two arguments: I call it "split compose", and it applies one function to the left argument and another to the right before passing them both to the middle function (if the functions on both sides are the same, that would be Over!). Although it turns out it's not needed in the one-argument case. You'll get the same result just by jamming the functions together. This is called a "train" and we should probably leave it for another tutorial before going too far off the rails.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KOKGlcO3LeKfnDEpIDg=">↗️</a><pre> <span class='Paren'>(</span><span class='Function'>↕÷-</span><span class='Modifier2'>⟜</span><span class='Number'>1</span><span class='Paren'>)</span> <span class='Number'>8</span> -⟨ 0 0.1428571428571428 0.2857142857142857 0.4285714285714285 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩ +⟨ 0 0.14285714285714285 0.2857142857142857 0.42857142857142855 0.5714285714285714 0.7142857142857143 0.8571428571428571 1 ⟩ </pre> <h2 id="base-decoding-continued"><a class="header" href="#base-decoding-continued">Base decoding continued</a></h2> <p>We're speeding up a bit now, so in the examples below it might take some time for you to break down what I did and why. Remember that you can open any expression in the REPL in order to change parts of it or view the syntax. And don't get discouraged just because of how long it takes to understand a line of code! First, you'll surely get faster in fitting the pieces together. Second, a line of BQN often has more code in it than a line in other languages, because primitives have such short names. Think about how much <em>functionality</em> you can read and understand rather than how few <em>lines</em> you get through.</p> diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html index 6c654cd7..52de145d 100644 --- a/docs/tutorial/expression.html +++ b/docs/tutorial/expression.html @@ -97,7 +97,7 @@ <p>You could use Power to take square roots and <em>n</em>-th roots, but BQN has a primitive <code><span class='Function'>√</span></code> for this purpose. If no left argument is provided, then it's the Square Root function; with a left argument it's called Root, and raises the right argument to the power of one divided by the left argument.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oiaIDIKMyDiiJogMjc=">↗️</a><pre> <span class='Function'>√</span> <span class='Number'>2</span> -1.414213562373095 +1.4142135623730951 <span class='Number'>3</span> <span class='Function'>√</span> <span class='Number'>27</span> 3 </pre> @@ -117,7 +117,7 @@ <p>I bet if you try hard you'll remember how much you hated learning to do exponentiation before multiplication and division before addition and subtraction. Didn't I tell you Earth was a confusing place? BQN treats all functions—not only primitives, but also the ones you define—the same way. They're evaluated from right to left, and parentheses form subexpressions that are evaluated entirely before they can be used.</p> <p>For a longer example, here's an expression for the <a href="https://en.wikipedia.org/wiki/Sphere#Enclosed_volume">volume of a sphere</a> with radius 2.</p> <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 +33.510321638291124 </pre> <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'> |
