aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Number
diff options
context:
space:
mode:
authorMarvin Borner2023-03-05 23:53:54 +0100
committerMarvin Borner2023-03-05 23:53:54 +0100
commit7a35dd8650535d1d31c8b152e1074d6f1ebcf8ad (patch)
treeebd3ea54f23f53b08e9e44d8a7e627b86cf98575 /std/Number
parent626e9d9f062230e97d764660a8d0d1c8c05b9fcb (diff)
Switched to prefixed listification
Diffstat (limited to 'std/Number')
-rw-r--r--std/Number/Binary.bruijn2
-rw-r--r--std/Number/Ternary.bruijn10
2 files changed, 3 insertions, 9 deletions
diff --git a/std/Number/Binary.bruijn b/std/Number/Binary.bruijn
index 2f0fbce..2900414 100644
--- a/std/Number/Binary.bruijn
+++ b/std/Number/Binary.bruijn
@@ -47,7 +47,7 @@ list! [0 z a¹ a⁰] ⧗ Binary → (List Bit)
a⁰ [b⁰ : 0]
:test (list! (+0b)) (empty)
-:test (list! (+6b)) (b⁰ : (b¹ : (b¹ : empty)))
+:test (list! (+6b)) (b⁰ : (b¹ : {}b¹))
# converts a list of bits to a binary number
binary! foldr up (+0b) ⧗ (List Bit) → Binary
diff --git a/std/Number/Ternary.bruijn b/std/Number/Ternary.bruijn
index 84f4d4a..d05caa0 100644
--- a/std/Number/Ternary.bruijn
+++ b/std/Number/Ternary.bruijn
@@ -142,7 +142,7 @@ mst [B.get t⁰ (0 z a⁻ a⁺ a⁰)] ⧗ Number → Trit
:test (mst (+42)) (t⁺)
# returns true if balanced ternary number is negative
-negative? [t⁻? (mst 0)] ⧗ Number → Boolean
+negative? t⁻? ∘ mst ⧗ Number → Boolean
<?‣ negative?
@@ -152,7 +152,7 @@ negative? [t⁻? (mst 0)] ⧗ Number → Boolean
:test (<?(+42)) (false)
# returns true if balanced ternary number is positive
-positive? [t⁺? (mst 0)] ⧗ Number → Boolean
+positive? t⁺? ∘ mst ⧗ Number → Boolean
>?‣ positive?
@@ -252,7 +252,6 @@ dec [~(0 z a⁻ a⁺ a⁰)] ⧗ Number → Number
:test (--(+42) =? (+41)) (true)
# adds two balanced ternary numbers (can introduce leading 0s)
-# second argument gets abstracted (performance)
add [[abs 1 →^0]] ⧗ Number → Number → Number
abs [c (0 z a⁻ a⁺ a⁰)]
b⁻ [1 ↑⁺(3 0 t⁻) ↑⁰(3 0 t⁰) ↑⁻(3 0 t⁰)]
@@ -276,7 +275,6 @@ add [[abs 1 →^0]] ⧗ Number → Number → Number
:test ((+42) + (+1) =? (+43)) (true)
# subs two balanced ternary numbers (can introduce leading 0s)
-# second argument gets abstracted (performance)
sub [[1 + -0]] ⧗ Number → Number → Number
…-… sub
@@ -289,7 +287,6 @@ sub [[1 + -0]] ⧗ Number → Number → Number
:test ((+42) - (+1) =? (+41)) (true)
# returns true if number is greater than other number
-# larger numbers should be second argument (performance)
gre? [[>?(1 - 0)]] ⧗ Number → Number → Boolean
…>?… gre?
@@ -299,7 +296,6 @@ gre? [[>?(1 - 0)]] ⧗ Number → Number → Boolean
:test ((+3) >? (+2)) (true)
# returns true if number is less than other number
-# smaller numbers should be second argument (performance)
les? \gre? ⧗ Number → Number → Boolean
…<?… les?
@@ -309,7 +305,6 @@ les? \gre? ⧗ Number → Number → Boolean
:test ((+3) <? (+2)) (false)
# returns true if number is less than or equal to other number
-# smaller numbers should be second argument (performance)
leq? [[¬(1 >? 0)]] ⧗ Number → Number → Boolean
…≤?… leq?
@@ -319,7 +314,6 @@ leq? [[¬(1 >? 0)]] ⧗ Number → Number → Boolean
:test ((+3) ≤? (+2)) (false)
# returns true if number is greater than or equal to other number
-# smaller numbers should be second argument (performance)
geq? \leq? ⧗ Number → Number → Boolean
…≥?… geq?