diff options
author | inoas <mail@inoas.com> | 2022-04-14 05:18:37 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-04-16 10:23:34 +0100 |
commit | f540741d192c6eb664d48a7f9aadb3fa3cd0974e (patch) | |
tree | 6497a4fc1e5ebe3cbff6fa9cb1c92fa5e1211cd0 /src | |
parent | 25b4022e833b0c338e8121006d993ad03a778795 (diff) | |
download | gleam_stdlib-f540741d192c6eb664d48a7f9aadb3fa3cd0974e.tar.gz gleam_stdlib-f540741d192c6eb664d48a7f9aadb3fa3cd0974e.zip |
remove absolute_difference()
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/float.gleam | 17 | ||||
-rw-r--r-- | src/gleam/int.gleam | 15 |
2 files changed, 1 insertions, 31 deletions
diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam index b04135f..0f824a7 100644 --- a/src/gleam/float.gleam +++ b/src/gleam/float.gleam @@ -228,21 +228,6 @@ pub fn absolute_value(float: Float) -> Float { } } -/// Returns the absolute difference of the inputs as a positive Float -/// -/// ## Examples -/// -/// > absolute_difference(-10.0, 10.0) -/// 20.0 -/// -/// > absolute_difference(0.0, -2.0) -/// 2.0 -/// -pub fn absolute_difference(a: Float, b: Float) -> Float { - a -. b - |> absolute_value() -} - /// Returns the results of the base being raised to the power of the /// exponent, as a `Float`. /// @@ -350,7 +335,7 @@ pub fn random(boundary_a: Float, boundary_b: Float) -> Float { } case min, max { min, _max if min == max -> min - min, max -> do_random_uniform() *. absolute_difference(min, max) +. min + min, max -> do_random_uniform() *. { max -. min } +. min } } diff --git a/src/gleam/int.gleam b/src/gleam/int.gleam index 67a3b7a..e637cd5 100644 --- a/src/gleam/int.gleam +++ b/src/gleam/int.gleam @@ -18,21 +18,6 @@ pub fn absolute_value(num: Int) -> Int { } } -/// Returns the absolute difference of the inputs as a positive Int -/// -/// ## Examples -/// -/// > absolute_difference(-10, 10) -/// 20 -/// -/// > absolute_difference(0.0, -2) -/// 2 -/// -pub fn absolute_difference(a: Int, b: Int) -> Int { - a - b - |> absolute_value() -} - /// Parses a given string as an int if possible. /// /// ## Examples |