diff options
Diffstat (limited to 'docs/doc')
| -rw-r--r-- | docs/doc/arithmetic.html | 81 | ||||
| -rw-r--r-- | docs/doc/index.html | 2 | ||||
| -rw-r--r-- | docs/doc/primitive.html | 12 |
3 files changed, 88 insertions, 7 deletions
diff --git a/docs/doc/arithmetic.html b/docs/doc/arithmetic.html index 2fd50a23..7e9b9b64 100644 --- a/docs/doc/arithmetic.html +++ b/docs/doc/arithmetic.html @@ -202,6 +202,87 @@ 1 </pre> <p>Unlike in APL, a left argument of 0 fails or returns a not-a-number result. Set <code><span class='Value'>𝕨</span></code> to <code><span class='Number'>∞</span></code> to keep <code><span class='Value'>𝕩</span></code> intact, but do note that if <code><span class='Value'>𝕩</span><span class='Function'><</span><span class='Number'>0</span></code> this will return <code><span class='Number'>∞</span></code>.</p> +<h2 id="comparisons">Comparisons</h2> +<p>BQN uses the six standard comparison functions of mathematics. For each pair of atoms the result is 1 if the comparison is true and 0 if it's false. These functions do the obvious thing with numeric arguments, but are extended to other types as well.</p> +<table> +<thead> +<tr> +<th>Name</th> +<th align="center">Glyph</th> +<th><</th> +<th>=</th> +<th>></th> +<th>Domain</th> +</tr> +</thead> +<tbody> +<tr> +<td>Equals</td> +<td align="center"><code><span class='Function'>=</span></code></td> +<td>0</td> +<td>1</td> +<td>0</td> +<td>Any</td> +</tr> +<tr> +<td>Not Equals</td> +<td align="center"><code><span class='Function'>≠</span></code></td> +<td>1</td> +<td>0</td> +<td>1</td> +<td>Any</td> +</tr> +<tr> +<td>Less Than or Equal to</td> +<td align="center"><code><span class='Function'>≤</span></code></td> +<td>1</td> +<td>1</td> +<td>0</td> +<td>Data</td> +</tr> +<tr> +<td>Less Than</td> +<td align="center"><code><span class='Function'><</span></code></td> +<td>1</td> +<td>0</td> +<td>0</td> +<td>Data</td> +</tr> +<tr> +<td>Greater Than</td> +<td align="center"><code><span class='Function'>></span></code></td> +<td>0</td> +<td>0</td> +<td>1</td> +<td>Data</td> +</tr> +<tr> +<td>Greater Than or Equal to</td> +<td align="center"><code><span class='Function'>≥</span></code></td> +<td>0</td> +<td>1</td> +<td>1</td> +<td>Data</td> +</tr> +</tbody> +</table> +<p>The <em>ordered</em> comparisons <code><span class='Function'>≤<>≥</span></code> are defined on numbers and characters (and arrays, by pervasion); they give an error for operation or namespace arguments. They order numbers as you'd expect, and characters by their code points. A character is considered greater than any number, even if it's <code><span class='Number'>∞</span></code>.</p> +<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=M+KAvzTigL814oC/NiDiiaQgNQoKJ2MnIDwgImFjYnoiCgrCr+KInuKAv8+A4oC/4oieIOKJpSBA4oC/JzAn4oC/Jz8n">↗️</a><pre> <span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Ligature'>‿</span><span class='Number'>5</span><span class='Ligature'>‿</span><span class='Number'>6</span> <span class='Function'>≤</span> <span class='Number'>5</span> +⟨ 1 1 1 0 ⟩ + + <span class='String'>'c'</span> <span class='Function'><</span> <span class='String'>"acbz"</span> +⟨ 0 0 0 1 ⟩ + + <span class='Number'>¯∞</span><span class='Ligature'>‿</span><span class='Number'>π</span><span class='Ligature'>‿</span><span class='Number'>∞</span> <span class='Function'>≥</span> <span class='String'>@</span><span class='Ligature'>‿</span><span class='String'>'0'</span><span class='Ligature'>‿</span><span class='String'>'?'</span> +⟨ 0 0 0 ⟩ +</pre> +<p>Equals and Not Equals are the two <em>equality</em> comparisons. Equals tests for <a href="match.html#atomic-equality">atomic equality</a> between each pair of atoms, as described in the Match documentation. Essentially, it returns <code><span class='Number'>1</span></code> only if the two values are indistinguishable to BQN and <code><span class='Number'>0</span></code> otherwise. Values of different types can never be equal, and characters are equal when they have the same code point.</p> +<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=K+KAvy3igL/Dl+KAv8O3ID0g4oqR4p+oLeKfqQoKJ2InIOKJoCAiYWJhY2JhIg==">↗️</a><pre> <span class='Function'>+</span><span class='Ligature'>‿</span><span class='Function'>-</span><span class='Ligature'>‿</span><span class='Function'>×</span><span class='Ligature'>‿</span><span class='Function'>÷</span> <span class='Function'>=</span> <span class='Function'>⊑</span><span class='Bracket'>⟨</span><span class='Function'>-</span><span class='Bracket'>⟩</span> +⟨ 0 1 0 0 ⟩ + + <span class='String'>'b'</span> <span class='Function'>≠</span> <span class='String'>"abacba"</span> +⟨ 1 0 1 1 0 1 ⟩ +</pre> <h2 id="pervasion">Pervasion</h2> <p>Arithmetic primitives act as though they are given <a href="depth.html#the-depth-modifier">depth</a> 0, so that with array arguments they treat each atom independently. While the examples above use only numbers or lists of them, arithmetic applies to nested and high-rank arrays just as easily.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=w5cg4omNy5jin6jCrzgswq854p+p4oC/4p+o4p+oMiww4p+pLDQsNeKfqQ==">↗️</a><pre> <span class='Function'>×</span> <span class='Function'>≍</span><span class='Modifier'>˘</span><span class='Bracket'>⟨</span><span class='Number'>¯8</span><span class='Separator'>,</span><span class='Number'>¯9</span><span class='Bracket'>⟩</span><span class='Ligature'>‿</span><span class='Bracket'>⟨⟨</span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>0</span><span class='Bracket'>⟩</span><span class='Separator'>,</span><span class='Number'>4</span><span class='Separator'>,</span><span class='Number'>5</span><span class='Bracket'>⟩</span> diff --git a/docs/doc/index.html b/docs/doc/index.html index 75a7e7f8..9c535aa2 100644 --- a/docs/doc/index.html +++ b/docs/doc/index.html @@ -34,7 +34,7 @@ </ul> <p>Primitives:</p> <ul> -<li><a href="arithmetic.html">Arithmetic</a> (<code><span class='Function'>+-×÷⋆√⌊⌈|</span></code>)</li> +<li><a href="arithmetic.html">Arithmetic</a> (<code><span class='Function'>+-×÷⋆√⌊⌈|≤<>≥=≠</span></code>)</li> <li><a href="depth.html">Array depth</a> (<code><span class='Function'>≡</span></code> and <code><span class='Modifier2'>⚇</span></code>)</li> <li><a href="shape.html">Array dimensions</a> (<code><span class='Function'>≢=≠</span></code>)</li> <li><a href="assert.html">Assert</a> (<code><span class='Function'>!</span></code>)</li> diff --git a/docs/doc/primitive.html b/docs/doc/primitive.html index 5c024ba8..ac4cac2d 100644 --- a/docs/doc/primitive.html +++ b/docs/doc/primitive.html @@ -82,32 +82,32 @@ <tr> <td><code><span class='Function'>≤</span></code></td> <td></td> -<td><a href="https://aplwiki.com/wiki/Less_than_or_Equal_to">Less Than or Equal to</a></td> +<td><a href="arithmetic.html#comparisons">Less Than or Equal to</a></td> </tr> <tr> <td><code><span class='Function'><</span></code></td> <td><a href="enclose.html">Enclose</a></td> -<td><a href="https://aplwiki.com/wiki/Less_than">Less Than</a></td> +<td><a href="arithmetic.html#comparisons">Less Than</a></td> </tr> <tr> <td><code><span class='Function'>></span></code></td> <td><a href="couple.html">Merge</a>*</td> -<td><a href="https://aplwiki.com/wiki/Greater_than">Greater Than</a></td> +<td><a href="arithmetic.html#comparisons">Greater Than</a></td> </tr> <tr> <td><code><span class='Function'>≥</span></code></td> <td></td> -<td><a href="https://aplwiki.com/wiki/Greater_than_or_Equal_to">Greater Than or Equal to</a></td> +<td><a href="arithmetic.html#comparisons">Greater Than or Equal to</a></td> </tr> <tr> <td><code><span class='Function'>=</span></code></td> <td><a href="shape.html">Rank</a>*</td> -<td><a href="https://aplwiki.com/wiki/Equal_to">Equals</a></td> +<td><a href="arithmetic.html#comparisons">Equals</a></td> </tr> <tr> <td><code><span class='Function'>≠</span></code></td> <td><a href="shape.html">Length</a></td> -<td><a href="https://aplwiki.com/wiki/Not_Equal_to">Not Equals</a></td> +<td><a href="arithmetic.html#comparisons">Not Equals</a></td> </tr> <tr> <td><code><span class='Function'>≡</span></code></td> |
