aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/README.md2
-rw-r--r--doc/arithmetic.md27
-rw-r--r--doc/primitive.md12
3 files changed, 34 insertions, 7 deletions
diff --git a/doc/README.md b/doc/README.md
index ab347e99..9e3f3e3a 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -28,7 +28,7 @@ Concepts:
- [Function trains](train.md)
Primitives:
-- [Arithmetic](arithmetic.md) (`+-×÷⋆√⌊⌈|`)
+- [Arithmetic](arithmetic.md) (`+-×÷⋆√⌊⌈|≤<>≥=≠`)
- [Array depth](depth.md) (`≡` and `⚇`)
- [Array dimensions](shape.md) (`≢=≠`)
- [Assert](assert.md) (`!`)
diff --git a/doc/arithmetic.md b/doc/arithmetic.md
index 3fa9ab9a..ee93b984 100644
--- a/doc/arithmetic.md
+++ b/doc/arithmetic.md
@@ -138,6 +138,33 @@ Modulus (`|`) is similar to the modular division operation written `%` in C-like
Unlike in APL, a left argument of 0 fails or returns a not-a-number result. Set `𝕨` to `∞` to keep `𝕩` intact, but do note that if `𝕩<0` this will return `∞`.
+## Comparisons
+
+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.
+
+| Name | Glyph | < | = | > | Domain
+|--------------------------|:-----:|---|---|---|-------
+| Equals | `=` | 0 | 1 | 0 | Any
+| Not Equals | `≠` | 1 | 0 | 1 | Any
+| Less Than or Equal to | `≤` | 1 | 1 | 0 | Data
+| Less Than | `<` | 1 | 0 | 0 | Data
+| Greater Than | `>` | 0 | 0 | 1 | Data
+| Greater Than or Equal to | `≥` | 0 | 1 | 1 | Data
+
+The *ordered* comparisons `≤<>≥` 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 `∞`.
+
+ 3‿4‿5‿6 ≤ 5
+
+ 'c' < "acbz"
+
+ ¯∞‿π‿∞ ≥ @‿'0'‿'?'
+
+Equals and Not Equals are the two *equality* comparisons. Equals tests for [atomic equality](match.md#atomic-equality) between each pair of atoms, as described in the Match documentation. Essentially, it returns `1` only if the two values are indistinguishable to BQN and `0` otherwise. Values of different types can never be equal, and characters are equal when they have the same code point.
+
+ +‿-‿×‿÷ = ⊑⟨-⟩
+
+ 'b' ≠ "abacba"
+
## Pervasion
Arithmetic primitives act as though they are given [depth](depth.md#the-depth-modifier) 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.
diff --git a/doc/primitive.md b/doc/primitive.md
index 531ffb13..ff40f843 100644
--- a/doc/primitive.md
+++ b/doc/primitive.md
@@ -26,12 +26,12 @@ Functions that have significant differences from APL functions are marked with a
| `∨` | [Sort Down](order.md#sort) | [Or](logic.md)*
| `¬` | [Not](logic.md)* | [Span](logic.md)*
| `\|` | [Absolute Value](arithmetic.md#additional-arithmetic)| [Modulus](arithmetic.md#additional-arithmetic)
-| `≤` | | [Less Than or Equal to](https://aplwiki.com/wiki/Less_than_or_Equal_to)
-| `<` | [Enclose](enclose.md) | [Less Than](https://aplwiki.com/wiki/Less_than)
-| `>` | [Merge](couple.md)* | [Greater Than](https://aplwiki.com/wiki/Greater_than)
-| `≥` | | [Greater Than or Equal to](https://aplwiki.com/wiki/Greater_than_or_Equal_to)
-| `=` | [Rank](shape.md)* | [Equals](https://aplwiki.com/wiki/Equal_to)
-| `≠` | [Length](shape.md) | [Not Equals](https://aplwiki.com/wiki/Not_Equal_to)
+| `≤` | | [Less Than or Equal to](arithmetic.md#comparisons)
+| `<` | [Enclose](enclose.md) | [Less Than](arithmetic.md#comparisons)
+| `>` | [Merge](couple.md)* | [Greater Than](arithmetic.md#comparisons)
+| `≥` | | [Greater Than or Equal to](arithmetic.md#comparisons)
+| `=` | [Rank](shape.md)* | [Equals](arithmetic.md#comparisons)
+| `≠` | [Length](shape.md) | [Not Equals](arithmetic.md#comparisons)
| `≡` | [Depth](depth.md)* | [Match](match.md)
| `≢` | [Shape](shape.md) | [Not Match](match.md)
| `⊣` | [Identity](identity.md) | [Left](identity.md)