aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Number/Ternary.bruijn
diff options
context:
space:
mode:
authorMarvin Borner2024-02-29 11:37:56 +0100
committerMarvin Borner2024-02-29 11:37:56 +0100
commit1f36d2506288f2039707b843f203bfa19176a1e3 (patch)
tree4caa82317b6c0e2397a40ffc7f893bf82f152b7d /std/Number/Ternary.bruijn
parent9af35d2f796d5952fc290b22b057614a0e9db9ad (diff)
Encourage use of combinators
Diffstat (limited to 'std/Number/Ternary.bruijn')
-rw-r--r--std/Number/Ternary.bruijn24
1 files changed, 12 insertions, 12 deletions
diff --git a/std/Number/Ternary.bruijn b/std/Number/Ternary.bruijn
index e1b3893..f63d9ac 100644
--- a/std/Number/Ternary.bruijn
+++ b/std/Number/Ternary.bruijn
@@ -90,9 +90,9 @@ list! [0 z a⁻ a⁺ a⁰] ⧗ Number → List
# strips leading 0s from a balanced ternary number
strip [^(0 z a⁻ a⁺ a⁰)] ⧗ Number → Number
z (+0) : true
- a⁻ [0 [[↑⁻1 : false]]]
- a⁺ [0 [[↑⁺1 : false]]]
- a⁰ [0 [[(0 (+0) ↑⁰1) : 0]]]
+ a⁻ &[[↑⁻1 : false]]
+ a⁺ &[[↑⁺1 : false]]
+ a⁰ &[[(0 (+0) ↑⁰1) : 0]]
%‣ strip
@@ -218,9 +218,9 @@ not-eq? not! ∘∘ eq? ⧗ Number → Number → Boolean
# adds (+1) to a balanced ternary number (can introduce leading 0s)
inc [~(0 z a⁻ a⁺ a⁰)] ⧗ Number → Number
z (+0) : (+1)
- a⁻ [0 [[↑⁻1 : ↑⁰1]]]
- a⁺ [0 [[↑⁺1 : ↑⁻0]]]
- a⁰ [0 [[↑⁰1 : ↑⁺1]]]
+ a⁻ &[[↑⁻1 : ↑⁰1]]
+ a⁺ &[[↑⁺1 : ↑⁻0]]
+ a⁰ &[[↑⁰1 : ↑⁺1]]
++‣ inc
@@ -233,9 +233,9 @@ inc [~(0 z a⁻ a⁺ a⁰)] ⧗ Number → Number
# subs (+1) from a balanced ternary number (can introduce leading 0s)
dec [~(0 z a⁻ a⁺ a⁰)] ⧗ Number → Number
z (+0) : (-1)
- a⁻ [0 [[↑⁻1 : ↑⁺0]]]
- a⁺ [0 [[↑⁺1 : ↑⁰1]]]
- a⁰ [0 [[↑⁰1 : ↑⁻1]]]
+ a⁻ &[[↑⁻1 : ↑⁺0]]
+ a⁺ &[[↑⁺1 : ↑⁰1]]
+ a⁰ &[[↑⁰1 : ↑⁻1]]
--‣ dec
@@ -366,9 +366,9 @@ mul [[1 z a⁻ a⁺ a⁰]] ⧗ Number → Number → Number
# WARNING: Not necessarily equivalent to (/ (+3)): e.g. /³(+5) == (+2)!
div³ [~(0 z a⁻ a⁺ a⁰)] ⧗ Number → Number
z (+0) : (+0)
- a⁻ [0 [[↑⁻1 : 1]]]
- a⁺ [0 [[↑⁺1 : 1]]]
- a⁰ [0 [[↑⁰1 : 1]]]
+ a⁻ &[[↑⁻1 : 1]]
+ a⁺ &[[↑⁺1 : 1]]
+ a⁰ &[[↑⁰1 : 1]]
/³‣ div³