diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/doc/block.html | 2 | ||||
| -rw-r--r-- | docs/doc/functional.html | 4 | ||||
| -rw-r--r-- | docs/doc/syntax.html | 2 | ||||
| -rw-r--r-- | docs/tutorial/expression.html | 16 | ||||
| -rw-r--r-- | docs/tutorial/list.html | 2 |
5 files changed, 13 insertions, 13 deletions
diff --git a/docs/doc/block.html b/docs/doc/block.html index 21354448..10896e93 100644 --- a/docs/doc/block.html +++ b/docs/doc/block.html @@ -94,7 +94,7 @@ </pre> <p>However, <code><span class='Nothing'>Β·</span></code> can only be used as an argument, and not a list element or operand. Don't use <code><span class='Value'>π¨</span></code> in these ways in a function that could be called monadically. Another potential issue is that <code><span class='Modifier2'>βΈ</span></code> and <code><span class='Modifier2'>β</span></code> don't work the way you might expect.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=eyDwnZWoIOKLhuKKuC0g8J2VqSB9IDU=">βοΈ</a><pre> <span class='Brace'>{</span> <span class='Value'>π¨</span> <span class='Function'>β</span><span class='Modifier2'>βΈ</span><span class='Function'>-</span> <span class='Value'>π©</span> <span class='Brace'>}</span> <span class='Number'>5</span> -143.413159102577 +143.4131591025766 </pre> <p>Called dyadically, this function will expand to <code><span class='Paren'>(</span><span class='Function'>β</span><span class='Value'>π¨</span><span class='Paren'>)</span><span class='Function'>-</span><span class='Value'>π©</span></code>, so we might expect the monadic result to be <code><span class='Function'>-</span><span class='Value'>π©</span></code>. This sort of expansion isn't right with <code><span class='Nothing'>Β·</span></code> on the left. <code><span class='Function'>β</span><span class='Modifier2'>βΈ</span><span class='Function'>-</span></code> taken as a whole is a function, so <code><span class='Nothing'>Β·</span> <span class='Function'>β</span><span class='Modifier2'>βΈ</span><span class='Function'>-</span> <span class='Value'>π©</span></code> is just <code><span class='Function'>β</span><span class='Modifier2'>βΈ</span><span class='Function'>-</span> <span class='Value'>π©</span></code>, or <code><span class='Paren'>(</span><span class='Function'>β</span><span class='Value'>π©</span><span class='Paren'>)</span><span class='Function'>-</span><span class='Value'>π©</span></code>, giving the large result seen above.</p> <h3 id="operands">Operands</h3> diff --git a/docs/doc/functional.html b/docs/doc/functional.html index 7debbe20..76dc6777 100644 --- a/docs/doc/functional.html +++ b/docs/doc/functional.html @@ -111,11 +111,11 @@ <p>Like any function, this one can be given a name and then called. A quirk of this way of defining a function is that it has a subject role (it's the result of the function <code><span class='Brace'>{</span><span class='Function'>π</span><span class='Modifier2'>β</span><span class='Function'>π</span><span class='Brace'>}</span><span class='Modifier'>Β΄</span></code>) and so must be defined with a lowercase name.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=Z2F1c3Mg4oaQIHvwnZWO4oiY8J2Vj33CtCDii4bigL8t4oC/KMOXy5wpCkdhdXNzIDI=">βοΈ</a><pre> <span class='Value'>gauss</span> <span class='Gets'>β</span> <span class='Brace'>{</span><span class='Function'>π</span><span class='Modifier2'>β</span><span class='Function'>π</span><span class='Brace'>}</span><span class='Modifier'>Β΄</span> <span class='Function'>β</span><span class='Ligature'>βΏ</span><span class='Function'>-</span><span class='Ligature'>βΏ</span><span class='Paren'>(</span><span class='Function'>Γ</span><span class='Modifier'>Λ</span><span class='Paren'>)</span> <span class='Function'>Gauss</span> <span class='Number'>2</span> -0.0183156388887342 +0.01831563888873418 </pre> <p>Another, and probably more common, use of arrays of functions is to apply several different functions to one or more arguments. Here we apply three different functions to the number 9:</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+o4oiaLCAy4oq44oi+LCDiiqIt4ouG4p+pIHvwnZWO8J2VqX3CqCA5">βοΈ</a><pre> <span class='Bracket'>β¨</span><span class='Function'>β</span><span class='Separator'>,</span> <span class='Number'>2</span><span class='Modifier2'>βΈ</span><span class='Function'>βΎ</span><span class='Separator'>,</span> <span class='Function'>β’-β</span><span class='Bracket'>β©</span> <span class='Brace'>{</span><span class='Function'>π</span><span class='Value'>π©</span><span class='Brace'>}</span><span class='Modifier'>Β¨</span> <span class='Number'>9</span> -β¨ 3 β¨ 2 9 β© Β―8094.08392757538 β© +β¨ 3 β¨ 2 9 β© Β―8094.083927575384 β© </pre> <p>The 2-modifier Choose (<code><span class='Modifier2'>βΆ</span></code>) relies on arrays of functions toβ¦ function. It's very closely related to Pick <code><span class='Function'>β</span></code>, and in fact when the left operand and the elements of the right operand are all data there's no real difference: Choose returns the constant function <code><span class='Value'>π</span><span class='Function'>β</span><span class='Value'>π</span></code>.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MuKXtiJhYmNkZWYiICJhcmci">βοΈ</a><pre> <span class='Number'>2</span><span class='Modifier2'>βΆ</span><span class='String'>"abcdef"</span> <span class='String'>"arg"</span> diff --git a/docs/doc/syntax.html b/docs/doc/syntax.html index 4f8eb345..88e006fc 100644 --- a/docs/doc/syntax.html +++ b/docs/doc/syntax.html @@ -108,7 +108,7 @@ <p>BQN has single-token notation for numbers, strings, and characters.</p> <p>Numbers allow the typical decimal notation with <code><span class='Number'>Β―</span></code> for the negative sign (because <code><span class='Function'>-</span></code> is a function) and <code><span class='Value'>e</span></code> for scientific notation (or <code><span class='Function'>E</span></code>, as numeric notation is case-insensitive). <code><span class='Number'>β</span></code> and <code><span class='Number'>Ο</span></code> may be used as special numeric values. If complex numbers are supported, then they can be written with the components separated by <code><span class='Value'>i</span></code>. However, no BQN to date supports complex numbers.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oIMKvz4Ag4ouEIDAuNSDii4QgNWXCrzEg4ouEIDEuNUUzIOKLhCDiiJ4g4p+pICAgIyBBIGxpc3Qgb2YgbnVtYmVycw==">βοΈ</a><pre> <span class='Bracket'>β¨</span> <span class='Number'>Β―Ο</span> <span class='Separator'>β</span> <span class='Number'>0.5</span> <span class='Separator'>β</span> <span class='Number'>5eΒ―1</span> <span class='Separator'>β</span> <span class='Number'>1.5E3</span> <span class='Separator'>β</span> <span class='Number'>β</span> <span class='Bracket'>β©</span> <span class='Comment'># A list of numbers -</span>β¨ Β―3.14159265358979 0.5 0.5 1500 β β© +</span>β¨ Β―3.141592653589793 0.5 0.5 1500 β β© </pre> <p>Strings are written with double quotes <code><span class='String'>""</span></code>, and characters with single quotes <code><span class='String'>''</span></code> with a single character in between. A double quote within a string can be escaped by writing it twice; if two string literals are next to each other, they must be separated by a space. In contrast, character literals do not use escapes, as the length is already known.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omgwqgg4p+oICJzdHIiIOKLhCAicyd0IiJyIiDii4QgJ2MnIOKLhCAnJycg4ouEICciJyDin6kgICAjICIiIGlzIGFuIGVzY2FwZQoK4omhwqgg4p+oICJhIiDii4QgJ2EnIOKfqSAgICMgQSBzdHJpbmcgaXMgYW4gYXJyYXkgYnV0IGEgY2hhcmFjdGVyIGlzbid0">βοΈ</a><pre> <span class='Function'>β </span><span class='Modifier'>Β¨</span> <span class='Bracket'>β¨</span> <span class='String'>"str"</span> <span class='Separator'>β</span> <span class='String'>"s't""r"</span> <span class='Separator'>β</span> <span class='String'>'c'</span> <span class='Separator'>β</span> <span class='String'>'''</span> <span class='Separator'>β</span> <span class='String'>'"'</span> <span class='Bracket'>β©</span> <span class='Comment'># "" is an escape diff --git a/docs/tutorial/expression.html b/docs/tutorial/expression.html index d1a1d32a..07b8c4f0 100644 --- a/docs/tutorial/expression.html +++ b/docs/tutorial/expression.html @@ -33,7 +33,7 @@ <p>Shown above are a few arithmetic operations. BQN manages to pass as a normal programming language for three lines so far. That's a big accomplishment for BQN! Earth's a confusing place!</p> <p>The number of spaces between <em>primitive functions</em> like <code><span class='Function'>+</span></code> and <code><span class='Function'>-</span></code> and their <em>arguments</em> doesn't matter: you can use as much or as little as you like. No spaces inside numbers, of course.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MiDDlyDPgAo5IMO3IDIKw7cg4oie">βοΈ</a><pre> <span class='Number'>2</span> <span class='Function'>Γ</span> <span class='Number'>Ο</span> -6.28318530717959 +6.283185307179586 <span class='Number'>9</span> <span class='Function'>Γ·</span> <span class='Number'>2</span> 4.5 <span class='Function'>Γ·</span> <span class='Number'>β</span> @@ -71,9 +71,9 @@ <span class='Number'>3</span> <span class='Function'>β</span> <span class='Number'>2</span> 9 <span class='Function'>β</span> <span class='Number'>1</span> <span class='Comment'># There's no constant for e but you can get it this way -</span>2.71828182845905 +</span>2.718281828459045 <span class='Function'>β</span> <span class='Number'>2.3</span> -9.97418245481472 +9.974182454814718 </pre> <table class='primitives'> <tr> @@ -92,7 +92,7 @@ <p>You could use Power to take square roots and <em>n</em>-th roots, but BQN also provides the primitive <code><span class='Function'>β</span></code> for this purpose. If no left argument is provided, then it is the Square Root function; with a left argument it is 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.4142135623731 +1.4142135623730951 <span class='Number'>3</span> <span class='Function'>β</span> <span class='Number'>27</span> 3 </pre> @@ -112,7 +112,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 just primitives but the ones you'll define as wellβthe same way. They are evaluated from right to left, and parentheses can be used to group subexpressions that have to be evaluated before being used as arguments.</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.5103216382911 +33.510321638291124 </pre> <p>The evaluation order is shown 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> <svg viewBox='-175.375 -34 512 188'> @@ -159,9 +159,9 @@ <h2 id="one-or-two-arguments">One or two arguments?</h2> <p>What about functions without a left argument? Let's find an equation with lots of square roots in itβ¦ <a href="https://en.wikipedia.org/wiki/Nested_radical#Denesting">looks good</a>.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oiaIDMgKyAyIMOXIOKImjIKMSArIOKImjI=">βοΈ</a><pre> <span class='Function'>β</span> <span class='Number'>3</span> <span class='Function'>+</span> <span class='Number'>2</span> <span class='Function'>Γ</span> <span class='Function'>β</span><span class='Number'>2</span> -2.4142135623731 +2.414213562373095 <span class='Number'>1</span> <span class='Function'>+</span> <span class='Function'>β</span><span class='Number'>2</span> -2.4142135623731 +2.414213562373095 </pre> <p>They are the same, and now you can't say that BQN is the most complicated thing on this particular page! Just to make sure, we can find the difference by subtracting them, but we need to put the left argument in parentheses:</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KOKImjMgKyAyw5fiiJoyKSAtIDEr4oiaMg==">βοΈ</a><pre> <span class='Paren'>(</span><span class='Function'>β</span><span class='Number'>3</span> <span class='Function'>+</span> <span class='Number'>2</span><span class='Function'>Γβ</span><span class='Number'>2</span><span class='Paren'>)</span> <span class='Function'>-</span> <span class='Number'>1</span><span class='Function'>+β</span><span class='Number'>2</span> @@ -317,7 +317,7 @@ </pre> <p>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> -2.30258509299405 +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> diff --git a/docs/tutorial/list.html b/docs/tutorial/list.html index 71ad8237..13760cbf 100644 --- a/docs/tutorial/list.html +++ b/docs/tutorial/list.html @@ -114,7 +114,7 @@ <h2 id="arithmetic-on-lists">Arithmetic on lists</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> -β¨ 0.5 0.333333333333333 0.25 β© +β¨ 0.5 0.3333333333333333 0.25 β© <span class='String'>"APL"</span> <span class='Function'>+</span> <span class='Number'>1</span> "BQM" |
