aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Number/Ternary.bruijn
diff options
context:
space:
mode:
authorMarvin Borner2024-03-13 15:22:05 +0100
committerMarvin Borner2024-03-13 15:22:05 +0100
commit004f853f260d321753af32318ecdeb2c585af7b0 (patch)
tree9910e17715c0a94325d3e79014cb5b5368af46a2 /std/Number/Ternary.bruijn
parent7fc946443adcef9224a3c672b5929a93489c8c93 (diff)
Better string comparison using prefixed spaceship operator
Co-authored-by: JoJoBarthold2 <valentin.j.schmidt@web.de>
Diffstat (limited to 'std/Number/Ternary.bruijn')
-rw-r--r--std/Number/Ternary.bruijn15
1 files changed, 13 insertions, 2 deletions
diff --git a/std/Number/Ternary.bruijn b/std/Number/Ternary.bruijn
index 8cf891f..5e93c66 100644
--- a/std/Number/Ternary.bruijn
+++ b/std/Number/Ternary.bruijn
@@ -348,7 +348,7 @@ geq? \leq? ⧗ Number → Number → Boolean
:test ((+2) ≥? (+2)) (true)
:test ((+3) ≥? (+2)) (true)
-# returns eq, lt, gt depending on comparison of two numbers
+# returns eq, gt, lt depending on comparison of two numbers
compare-case [[[[[go (1 - 0)]]]]] ⧗ a → b → c → Number → Number → d
go [=?0 5 (>?0 4 3)]
@@ -356,11 +356,22 @@ compare-case [[[[[go (1 - 0)]]]]] ⧗ a → b → c → Number → Number → d
# also: spaceship operator
compare compare-case (+0) (+1) (-1) ⧗ Number → Number → Number
+…<=>… compare
+
+<=>‣ &compare
+
:test (compare (+2) (+2)) ((+0))
:test (compare (+2) (+1)) ((+1))
:test (compare (+1) (+2)) ((-1))
-…<=>… compare
+# returns true if comparison result is equal (EQ)
+c-eq? eq? (+0) ⧗ Number → Number
+
+# returns true if comparison result is less than (LT)
+c-les? eq? (-1) ⧗ Number → Number
+
+# returns true if comparison result is greater than (GT)
+c-gre? eq? (+1) ⧗ Number → Number
# negates a balanced ternary number if <0
abs [<?0 -0 0] ⧗ Number → Number