aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Number
diff options
context:
space:
mode:
authorMarvin Borner2023-03-07 00:20:52 +0100
committerMarvin Borner2023-03-07 00:22:22 +0100
commitea98cabbe4515bd5248f44214ad870858f1594aa (patch)
tree85b5a52a10dec556729f8c04a73e6b3e415ed07b /std/Number
parent9ef10406c067d0a0532d609212a94519af402b87 (diff)
Useful additions
hehe
Diffstat (limited to 'std/Number')
-rw-r--r--std/Number/Ternary.bruijn11
1 files changed, 9 insertions, 2 deletions
diff --git a/std/Number/Ternary.bruijn b/std/Number/Ternary.bruijn
index d05caa0..9fb075e 100644
--- a/std/Number/Ternary.bruijn
+++ b/std/Number/Ternary.bruijn
@@ -322,9 +322,16 @@ geq? \leq? ⧗ Number → Number → Boolean
:test ((+2) ≥? (+2)) (true)
:test ((+3) ≥? (+2)) (true)
+# returns eq, lt, gt depending on comparison of two functions
+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
-compare [[go (1 - 0)]] ⧗ Number → Number → Number
- go [=?0 (+0) (>?0 (+1) (-1))]
+compare compare-case (+0) (+1) (-1) ⧗ Number → Number → Number
+
+:test (compare (+2) (+2)) ((+0))
+:test (compare (+2) (+1)) ((+1))
+:test (compare (+1) (+2)) ((-1))
# negates a balanced ternary number if <0
abs [<?0 -0 0] ⧗ Number → Number