aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/math
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/math')
-rw-r--r--stdlib/source/library/lux/math/number/frac.lux4
-rw-r--r--stdlib/source/library/lux/math/number/i64.lux4
-rw-r--r--stdlib/source/library/lux/math/number/int.lux6
-rw-r--r--stdlib/source/library/lux/math/number/nat.lux16
-rw-r--r--stdlib/source/library/lux/math/number/rev.lux48
-rw-r--r--stdlib/source/library/lux/math/random.lux4
6 files changed, 41 insertions, 41 deletions
diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux
index aff22f26d..77b54b4da 100644
--- a/stdlib/source/library/lux/math/number/frac.lux
+++ b/stdlib/source/library/lux/math/number/frac.lux
@@ -358,8 +358,8 @@
(def: .public (factorial it)
(-> Nat Nat)
- (loop [acc 1
- it it]
+ (loop (again [acc 1
+ it it])
(if (//nat.> 1 it)
(again (//nat.* it acc) (-- it))
acc)))
diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux
index 3dcd42f8b..927765984 100644
--- a/stdlib/source/library/lux/math/number/i64.lux
+++ b/stdlib/source/library/lux/math/number/i64.lux
@@ -148,8 +148,8 @@
(let [size (..left_shifted power 1)
repetitions (is (-> Nat Text Text)
(function (_ times char)
- (loop [iterations 1
- output char]
+ (loop (again [iterations 1
+ output char])
(if (n.< times iterations)
(again (++ iterations)
("lux text concat" char output))
diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux
index 7d8d19fe6..3b02cfa6e 100644
--- a/stdlib/source/library/lux/math/number/int.lux
+++ b/stdlib/source/library/lux/math/number/int.lux
@@ -134,9 +134,9 @@
... https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
(def: .public (extended_gcd a b)
(-> Int Int [[Int Int] Int])
- (loop [x +1 x1 +0
- y +0 y1 +1
- a1 a b1 b]
+ (loop (again [x +1 x1 +0
+ y +0 y1 +1
+ a1 a b1 b])
(case b1
+0 [[x y] a1]
_ (let [q (/ b1 a1)]
diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux
index 31537c887..da1670111 100644
--- a/stdlib/source/library/lux/math/number/nat.lux
+++ b/stdlib/source/library/lux/math/number/nat.lux
@@ -292,8 +292,8 @@
(def: encoded
(let [mask (|> 1 ("lux i64 left-shift" <shift>) --)]
(function (_ value)
- (loop [input value
- output ""]
+ (loop (again [input value
+ output ""])
(let [output' ("lux text concat"
(<to_character> ("lux i64 and" mask input))
output)]
@@ -307,8 +307,8 @@
(def: (decoded repr)
(let [input_size ("lux text size" repr)]
(if (..> 0 input_size)
- (loop [idx 0
- output 0]
+ (loop (again [idx 0
+ output 0])
(if (..< input_size idx)
(case (<to_value> ("lux text char" idx repr))
{.#Some digit_value}
@@ -331,8 +331,8 @@
(Codec Text Nat)
(def: (encoded value)
- (loop [input value
- output ""]
+ (loop (again [input value
+ output ""])
(let [digit (decimal_character (..% 10 input))
output' ("lux text concat" digit output)]
(case (../ 10 input)
@@ -346,8 +346,8 @@
(let [input_size ("lux text size" repr)]
(with_expansions [<failure> {try.#Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}]
(if (..> 0 input_size)
- (loop [idx 0
- output 0]
+ (loop (again [idx 0
+ output 0])
(if (..< input_size idx)
(case (decimal_value ("lux text char" idx repr))
{.#None}
diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux
index 31aa1799b..6fed06ede 100644
--- a/stdlib/source/library/lux/math/number/rev.lux
+++ b/stdlib/source/library/lux/math/number/rev.lux
@@ -235,8 +235,8 @@
_ 1))
raw_size ("lux text size" raw_output)
zero_padding (is Text
- (loop [zeroes_left (is Nat (//nat.- raw_size max_num_chars))
- output (is Text "")]
+ (loop (again [zeroes_left (is Nat (//nat.- raw_size max_num_chars))
+ output (is Text "")])
(if (//nat.= 0 zeroes_left)
output
(again (-- zeroes_left)
@@ -295,9 +295,9 @@
(def: (digits#times_5! idx output)
(-> Nat Digits Digits)
- (loop [idx idx
- carry 0
- output output]
+ (loop (again [idx idx
+ carry 0
+ output output])
(if (//int.< +0 (.int idx))
output
(let [raw (|> (..digit idx output)
@@ -309,9 +309,9 @@
(def: (power_digits power)
(-> Nat Digits)
- (loop [times power
- output (|> (..digits [])
- (digits#put! power 1))]
+ (loop (again [times power
+ output (|> (..digits [])
+ (digits#put! power 1))])
(if (//int.< +0 (.int times))
output
(again (-- times)
@@ -319,9 +319,9 @@
(def: (format digits)
(-> Digits Text)
- (loop [idx (-- //i64.width)
- all_zeroes? true
- output ""]
+ (loop (again [idx (-- //i64.width)
+ all_zeroes? true
+ output ""])
(if (//int.< +0 (.int idx))
(if all_zeroes?
"0"
@@ -338,9 +338,9 @@
(def: (digits#+! param subject)
(-> Digits Digits Digits)
- (loop [idx (-- //i64.width)
- carry 0
- output (..digits [])]
+ (loop (again [idx (-- //i64.width)
+ carry 0
+ output (..digits [])])
(if (//int.< +0 (.int idx))
output
(let [raw ($_ //nat.+
@@ -356,8 +356,8 @@
(let [length ("lux text size" input)]
(if (//nat.> //i64.width length)
{.#None}
- (loop [idx 0
- output (..digits [])]
+ (loop (again [idx 0
+ output (..digits [])])
(if (//nat.< length idx)
(case ("lux text index" 0 ("lux text clip" idx 1 input) "0123456789")
{.#None}
@@ -370,7 +370,7 @@
(def: (digits#< param subject)
(-> Digits Digits Bit)
- (loop [idx 0]
+ (loop (again [idx 0])
(and (//nat.< //i64.width idx)
(let [pd (..digit idx param)
sd (..digit idx subject)]
@@ -392,8 +392,8 @@
(def: (digits#-! param subject)
(-> Digits Digits Digits)
- (loop [idx (-- //i64.width)
- output subject]
+ (loop (again [idx (-- //i64.width)
+ output subject])
(if (//int.< +0 (.int idx))
output
(again (-- idx)
@@ -409,8 +409,8 @@
input
(let [last_idx (-- //i64.width)]
- (loop [idx last_idx
- digits (..digits [])]
+ (loop (again [idx last_idx
+ digits (..digits [])])
(if (//int.< +0 (.int idx))
("lux text concat" "." (..format digits))
(if (//i64.one? idx input)
@@ -434,9 +434,9 @@
(if (and dotted? within_limits?)
(case (|> input ..decimals ..text_digits)
{.#Some digits}
- (loop [digits digits
- idx 0
- output 0]
+ (loop (again [digits digits
+ idx 0
+ output 0])
(if (//nat.< //i64.width idx)
(let [power (power_digits idx)]
(if (digits#< power digits)
diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux
index c172e5c98..9b6153dfb 100644
--- a/stdlib/source/library/lux/math/random.lux
+++ b/stdlib/source/library/lux/math/random.lux
@@ -269,7 +269,7 @@
(if (n.> 0 size)
(do [! ..monad]
[xs (set hash (-- size) value_gen)]
- (loop [_ []]
+ (loop (again [_ []])
(do !
[x value_gen
.let [xs+ (set.has x xs)]]
@@ -283,7 +283,7 @@
(if (n.> 0 size)
(do [! ..monad]
[kv (dictionary hash (-- size) key_gen value_gen)]
- (loop [_ []]
+ (loop (again [_ []])
(do !
[k key_gen
v value_gen