aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/math/number/rev.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/math/number/rev.lux')
-rw-r--r--stdlib/source/library/lux/math/number/rev.lux48
1 files changed, 24 insertions, 24 deletions
diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux
index 4eea3ecf7..3fc60202c 100644
--- a/stdlib/source/library/lux/math/number/rev.lux
+++ b/stdlib/source/library/lux/math/number/rev.lux
@@ -119,7 +119,7 @@
("lux i64 +" top))))
(def: even_one (//i64.right_rotated 1 1))
-(def: odd_one (dec 0))
+(def: odd_one (-- 0))
(def: (even_reciprocal numerator)
(-> Nat Nat)
@@ -205,8 +205,8 @@
(Enum Rev)
(def: &order ..order)
- (def: succ inc)
- (def: pred dec))
+ (def: succ ++)
+ (def: pred --))
(implementation: .public interval
(Interval Rev)
@@ -229,7 +229,7 @@
(def: (decimals input)
(-> Text Text)
- ("lux text clip" 1 (dec ("lux text size" input)) input))
+ ("lux text clip" 1 (-- ("lux text size" input)) input))
(template [<struct> <codec> <char_bit_size> <error>]
[(with_expansions [<error_output> (as_is (#try.Failure ("lux text concat" <error> repr)))]
@@ -248,7 +248,7 @@
output (: Text "")]
(if (//nat.= 0 zeroes_left)
output
- (recur (dec zeroes_left)
+ (recur (-- zeroes_left)
("lux text concat" "0" output)))))]
(|> raw_output
("lux text concat" zero_padding)
@@ -311,7 +311,7 @@
(let [raw (|> (..digit idx output)
(//nat.* 5)
(//nat.+ carry))]
- (recur (dec idx)
+ (recur (-- idx)
(//nat./ 10 raw)
(digits\put! idx (//nat.% 10 raw) output)))
output)))
@@ -322,21 +322,21 @@
output (|> (..digits [])
(digits\put! power 1))]
(if (//int.>= +0 (.int times))
- (recur (dec times)
+ (recur (-- times)
(digits\times_5! power output))
output)))
(def: (format digits)
(-> Digits Text)
- (loop [idx (dec //i64.width)
+ (loop [idx (-- //i64.width)
all_zeroes? true
output ""]
(if (//int.>= +0 (.int idx))
(let [digit (..digit idx digits)]
(if (and (//nat.= 0 digit)
all_zeroes?)
- (recur (dec idx) true output)
- (recur (dec idx)
+ (recur (-- idx) true output)
+ (recur (-- idx)
false
("lux text concat"
(\ //nat.decimal encode digit)
@@ -347,7 +347,7 @@
(def: (digits\+! param subject)
(-> Digits Digits Digits)
- (loop [idx (dec //i64.width)
+ (loop [idx (-- //i64.width)
carry 0
output (..digits [])]
(if (//int.>= +0 (.int idx))
@@ -355,7 +355,7 @@
carry
(..digit idx param)
(..digit idx subject))]
- (recur (dec idx)
+ (recur (-- idx)
(//nat./ 10 raw)
(digits\put! idx (//nat.% 10 raw) output)))
output)))
@@ -372,7 +372,7 @@
#.None
(#.Some digit)
- (recur (inc idx)
+ (recur (++ idx)
(digits\put! idx digit output)))
(#.Some output)))
#.None)))
@@ -384,7 +384,7 @@
(let [pd (..digit idx param)
sd (..digit idx subject)]
(if (//nat.= pd sd)
- (recur (inc idx))
+ (recur (++ idx))
(//nat.< pd sd))))))
(def: (digits\-!' idx param subject)
@@ -397,14 +397,14 @@
(//nat.- param))]
(|> subject
(digits\put! idx diff)
- (digits\-!' (dec idx) 1))))))
+ (digits\-!' (-- idx) 1))))))
(def: (digits\-! param subject)
(-> Digits Digits Digits)
- (loop [idx (dec //i64.width)
+ (loop [idx (-- //i64.width)
output subject]
(if (//int.>= +0 (.int idx))
- (recur (dec idx)
+ (recur (-- idx)
(digits\-!' idx (..digit idx param) output))
output)))
@@ -417,16 +417,16 @@
".0"
input
- (let [last_idx (dec //i64.width)]
+ (let [last_idx (-- //i64.width)]
(loop [idx last_idx
digits (..digits [])]
(if (//int.>= +0 (.int idx))
(if (//i64.one? idx input)
(let [digits' (digits\+! (power_digits (//nat.- idx last_idx))
digits)]
- (recur (dec idx)
+ (recur (-- idx)
digits'))
- (recur (dec idx)
+ (recur (-- idx)
digits))
("lux text concat" "." (..format digits))
)))))
@@ -438,7 +438,7 @@
_
false)
- within_limits? (//nat.<= (inc //i64.width)
+ within_limits? (//nat.<= (++ //i64.width)
("lux text size" input))]
(if (and dotted? within_limits?)
(case (|> input ..decimals ..text_digits)
@@ -450,10 +450,10 @@
(let [power (power_digits idx)]
(if (digits\< power digits)
... Skip power
- (recur digits (inc idx) output)
+ (recur digits (++ idx) output)
(recur (digits\-! power digits)
- (inc idx)
- (//i64.one (//nat.- idx (dec //i64.width)) output))))
+ (++ idx)
+ (//i64.one (//nat.- idx (-- //i64.width)) output))))
(#try.Success (.rev output))))
#.None