diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/doc/arithmetic.html | 2 | ||||
| -rw-r--r-- | docs/doc/fold.html | 2 | ||||
| -rw-r--r-- | docs/doc/under.html | 2 | ||||
| -rw-r--r-- | docs/help/exponential_power.html | 4 | ||||
| -rw-r--r-- | docs/help/squareroot_root.html | 6 | ||||
| -rw-r--r-- | docs/implementation/kclaims.html | 12 | ||||
| -rw-r--r-- | docs/tutorial/combinator.html | 6 | ||||
| -rw-r--r-- | docs/tutorial/expression.html | 4 |
8 files changed, 19 insertions, 19 deletions
diff --git a/docs/doc/arithmetic.html b/docs/doc/arithmetic.html index 918bd9c5..7c8a900a 100644 --- a/docs/doc/arithmetic.html +++ b/docs/doc/arithmetic.html @@ -94,7 +94,7 @@ ⟨ 1 2.718281828459045 7.38905609893065 ⟩ <span class='Function'>√</span> <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>4</span> -⟨ 0 1 1.414213562373095 2 ⟩ +⟨ 0 1 1.4142135623730951 2 ⟩ </pre> <p>Take note of the difference between the function <code><span class='Function'>-</span></code>, and the "high minus" character <code><span class='Number'>¯</span></code>, which is a part of <a href="token.html#numbers">numeric notation</a>. Also shown is the number <code><span class='Number'>∞</span></code>, which BQN supports along with <code><span class='Number'>¯∞</span></code> (but depending on implementation BQN may or may not keep track of <code><span class='Number'>¯0</span></code>. Integer optimization loses the distinction so it's best not to rely on it).</p> <p>The logarithm is written with <a href="undo.html">Undo</a>: <code><span class='Function'>⋆</span><span class='Modifier'>⁼</span></code>. As with Power, the default base is <em>e</em>, giving a natural logarithm.</p> diff --git a/docs/doc/fold.html b/docs/doc/fold.html index d59caf97..4d73e8c0 100644 --- a/docs/doc/fold.html +++ b/docs/doc/fold.html @@ -151,7 +151,7 @@ </pre> <p>And the operand <code><span class='Function'>+</span><span class='Modifier2'>⟜</span><span class='Function'>÷</span></code> is a quick way to compute a <a href="https://en.wikipedia.org/wiki/Continued_fraction">continued fraction</a>'s value from a list of numbers. Here are a few terms from the continued fraction for <em>e</em>.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=K+KfnMO3wrQgMuKAvzHigL8y4oC/MeKAvzHigL804oC/MeKAvzE=">↗️</a><pre> <span class='Function'>+</span><span class='Modifier2'>⟜</span><span class='Function'>÷</span><span class='Modifier'>´</span> <span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>1</span> -2.71830985915493 +2.7183098591549295 </pre> <h3 id="initial-element"><a class="header" href="#initial-element">Initial element</a></h3> <p>When <code><span class='Function'>𝔽</span></code> isn't just an arithmetic primitive, folding with no initial element can be dangerous. Even if you know <code><span class='Value'>𝕩</span></code> isn't empty, saving you from an "Identity not found" error, the case with only one element can easily violate expectations. Here's a somewhat silly example of a function meant to merge elements of the argument into a single list (<code><span class='Function'>∾⥊</span><span class='Modifier'>¨</span></code> is a much better way to do this):</p> diff --git a/docs/doc/under.html b/docs/doc/under.html index 4ec761a8..df79f48c 100644 --- a/docs/doc/under.html +++ b/docs/doc/under.html @@ -82,7 +82,7 @@ <h2 id="computational-under"><a class="header" href="#computational-under">Computational Under</a></h2> <p>Computational Under is based on <a href="undo.html">Undo</a> (<code><span class='Modifier'>⁼</span></code>), and applies whenever structural Under doesn't. It's still limited, because Undo doesn't work on many or even most functions. One common use is with the square function <code><span class='Function'>×</span><span class='Modifier'>˜</span></code>, for computations such as finding the magnitude of a vector, or a <a href="https://en.wikipedia.org/wiki/Root_mean_square">root-mean-square</a> average like the one below.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KCvCtMO34omgKeKMvijDl8ucKSAy4oC/M+KAvzTigL81">↗️</a><pre> <span class='Paren'>(</span><span class='Function'>+</span><span class='Modifier'>´</span><span class='Function'>÷≠</span><span class='Paren'>)</span><span class='Modifier2'>⌾</span><span class='Paren'>(</span><span class='Function'>×</span><span class='Modifier'>˜</span><span class='Paren'>)</span> <span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>5</span> -3.674234614174767 +3.6742346141747673 </pre> <p>This average is the square root of the average of the squares of the arguments, and <code><span class='Modifier2'>⌾</span></code> lets us combine the two square-y steps. Here there are two possible solutions because <code><span class='Number'>¯3.67</span><span class='Value'>…</span></code> has the same square as the positive result; BQN of course uses the principal root. Similarly, <code><span class='Modifier2'>⌾</span><span class='Function'>÷</span></code> can be used for a harmonic sum or mean (you might notice that computational Under is a lot more mathy than the structural one).</p> <p>Under is the idiomatic way to do a round-to-nearest function:</p> diff --git a/docs/help/exponential_power.html b/docs/help/exponential_power.html index c21f9479..f3477fa6 100644 --- a/docs/help/exponential_power.html +++ b/docs/help/exponential_power.html @@ -10,7 +10,7 @@ <p><code><span class='Value'>e</span></code> (Euler's constant) to the power of <code><span class='Value'>𝕩</span></code>.</p> <p><a href="../doc/arithmetic.html#pervasion">Pervasive.</a></p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4ouGIDDigL8x4oC/MuKAvzM=">↗️</a><pre> <span class='Function'>⋆</span> <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span> -⟨ 1 2.718281828459045 7.38905609893065 20.08553692318767 ⟩ +⟨ 1 2.718281828459045 7.38905609893065 20.085536923187668 ⟩ </pre> <h2 id="𝕨--𝕩-power"><a class="header" href="#𝕨--𝕩-power"><code><span class='Value'>𝕨</span> <span class='Function'>⋆</span> <span class='Value'>𝕩</span></code>: Power</a></h2> <p><a class="fulldoc" href="../doc/arithmetic.html#basic-arithmetic">→full documentation</a></p> @@ -23,5 +23,5 @@ ⟨ 64 25 81 ⟩ <span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span> <span class='Function'>⋆</span> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>¯4</span> -⟨ 8 0.01234567901234568 ⟩ +⟨ 8 0.012345679012345678 ⟩ </pre> diff --git a/docs/help/squareroot_root.html b/docs/help/squareroot_root.html index 21c88b38..43ed980d 100644 --- a/docs/help/squareroot_root.html +++ b/docs/help/squareroot_root.html @@ -9,15 +9,15 @@ <p><a class="fulldoc" href="../doc/arithmetic.html#basic-arithmetic">→full documentation</a></p> <p><a href="../doc/arithmetic.html#pervasion">Pervasive.</a></p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oiaIDI=">↗️</a><pre> <span class='Function'>√</span> <span class='Number'>2</span> -1.414213562373095 +1.4142135623730951 </pre> <h2 id="𝕨--𝕩-root"><a class="header" href="#𝕨--𝕩-root"><code><span class='Value'>𝕨</span> <span class='Function'>√</span> <span class='Value'>𝕩</span></code>: Root</a></h2> <p><a class="fulldoc" href="../doc/arithmetic.html#basic-arithmetic">→full documentation</a></p> <p><code><span class='Value'>𝕨</span></code>th root of <code><span class='Value'>𝕩</span></code>.</p> <p><a href="../doc/arithmetic.html#pervasion">Pervasive.</a></p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDiiJogMgoKMeKAvzLigL8z4oC/NCDiiJogNA==">↗️</a><pre> <span class='Number'>2</span> <span class='Function'>√</span> <span class='Number'>2</span> -1.414213562373095 +1.4142135623730951 <span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span> <span class='Function'>√</span> <span class='Number'>4</span> -⟨ 4 2 1.587401051968199 1.414213562373095 ⟩ +⟨ 4 2 1.5874010519681994 1.4142135623730951 ⟩ </pre> diff --git a/docs/implementation/kclaims.html b/docs/implementation/kclaims.html index d11de34a..83876814 100644 --- a/docs/implementation/kclaims.html +++ b/docs/implementation/kclaims.html @@ -86,12 +86,12 @@ <p>Dividing the stall number by total cycles gives us percentage of program time that can be attributed to L1 instruction misses.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=bCDihpAgIkoi4oC/IkJRTiLigL8iQlFOIuKAvyJQeXRob24iCmwg4omNy5ggMTAwIMOXIDU24oC/NC414oC/NDk04oC/MjUgw7cgMV80NTfigL8yMzLigL81XzYzM+KAvzQ5OQ==">↗️</a><pre> <span class='Value'>l</span> <span class='Gets'>←</span> <span class='String'>"J"</span><span class='Ligature'>‿</span><span class='String'>"BQN"</span><span class='Ligature'>‿</span><span class='String'>"BQN"</span><span class='Ligature'>‿</span><span class='String'>"Python"</span> <span class='Value'>l</span> <span class='Function'>≍</span><span class='Modifier'>˘</span> <span class='Number'>100</span> <span class='Function'>×</span> <span class='Number'>56</span><span class='Ligature'>‿</span><span class='Number'>4.5</span><span class='Ligature'>‿</span><span class='Number'>494</span><span class='Ligature'>‿</span><span class='Number'>25</span> <span class='Function'>÷</span> <span class='Number'>1_457</span><span class='Ligature'>‿</span><span class='Number'>232</span><span class='Ligature'>‿</span><span class='Number'>5_633</span><span class='Ligature'>‿</span><span class='Number'>499</span> -┌─ -╵ "J" 3.843514070006863 - "BQN" 1.939655172413793 - "BQN" 8.76974968933073 - "Python" 5.01002004008016 - ┘ +┌─ +╵ "J" 3.8435140700068633 + "BQN" 1.9396551724137931 + "BQN" 8.76974968933073 + "Python" 5.01002004008016 + ┘ </pre> <p>So, roughly 4%, 2 to 9%, and 5%. The cache miss counts are also broadly in line with these numbers. Note that full cache misses are pretty rare, so that most misses just hit L2 or L3 and don't suffer a large penalty. Also note that instruction cache misses are mostly lower than data misses, as expected.</p> <p>Don't get me wrong, I'd love to improve performance even by 2%. But it's not exactly world domination, is it? The perf results are an upper bound for how much these programs could be sped up with better treatment of the instruction cache. If K is faster by more than that, it's because of other optimizations.</p> 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'> |
