aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Number/Ternary.bruijn
diff options
context:
space:
mode:
authorMarvin Borner2023-04-08 17:14:54 +0200
committerMarvin Borner2023-04-08 17:14:54 +0200
commit67b6713b221a25763d1c08e12e8b715d432db5f8 (patch)
tree40843861e9aaacc47beba57479c0b78bcfea8f08 /std/Number/Ternary.bruijn
parent5e5069c5228f2cd39de38ace9134f57293cc7e5d (diff)
Various improvements to standard library docs
Diffstat (limited to 'std/Number/Ternary.bruijn')
-rw-r--r--std/Number/Ternary.bruijn3
1 files changed, 3 insertions, 0 deletions
diff --git a/std/Number/Ternary.bruijn b/std/Number/Ternary.bruijn
index 9fb075e..f115349 100644
--- a/std/Number/Ternary.bruijn
+++ b/std/Number/Ternary.bruijn
@@ -327,12 +327,15 @@ compare-case [[[[[go (1 - 0)]]]]] ⧗ a → b → c → Number → Number → d
go [=?0 5 (>?0 4 3)]
# returns 1 if a>b, -1 if a<b and 0 if a=b
+# also: spaceship operator
compare compare-case (+0) (+1) (-1) ⧗ Number → Number → Number
:test (compare (+2) (+2)) ((+0))
:test (compare (+2) (+1)) ((+1))
:test (compare (+1) (+2)) ((-1))
+…<=>… compare
+
# negates a balanced ternary number if <0
abs [<?0 -0 0] ⧗ Number → Number