From ea98cabbe4515bd5248f44214ad870858f1594aa Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 7 Mar 2023 00:20:52 +0100 Subject: Useful additions hehe --- std/Number/Ternary.bruijn | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'std/Number/Ternary.bruijn') 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?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 [