From 016a32f7f798efefbf0376f07ecd12868b8160f3 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 12 Jun 2021 22:23:58 -0400 Subject: Add comparison functions to arithmetic documentation --- docs/doc/arithmetic.html | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/doc/index.html | 2 +- docs/doc/primitive.html | 12 +++---- 3 files changed, 88 insertions(+), 7 deletions(-) (limited to 'docs/doc') 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

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.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameGlyph<=>Domain
Equals=010Any
Not Equals101Any
Less Than or Equal to110Data
Less Than<100Data
Greater Than>001Data
Greater Than or Equal to011Data
+

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 .

+↗️
    3456  5
+⟨ 1 1 1 0 ⟩
+
+    'c' < "acbz"
+⟨ 0 0 0 1 ⟩
+
+    ¯∞π  @'0''?'
+⟨ 0 0 0 ⟩
+
+

Equals and Not Equals are the two equality comparisons. Equals tests for 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.

+↗️
    +-×÷ = -
+⟨ 0 1 0 0 ⟩
+
+    'b'  "abacba"
+⟨ 1 0 1 1 0 1 ⟩
+

Pervasion

Arithmetic primitives act as though they are given depth 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.

↗️
    × ˘¯8,¯9⟨⟨2,0,4,5
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 @@
 
 

Primitives: