From f540741d192c6eb664d48a7f9aadb3fa3cd0974e Mon Sep 17 00:00:00 2001 From: inoas Date: Thu, 14 Apr 2022 05:18:37 +0200 Subject: remove absolute_difference() --- src/gleam/float.gleam | 17 +---------------- src/gleam/int.gleam | 15 --------------- 2 files changed, 1 insertion(+), 31 deletions(-) (limited to 'src') 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 -- cgit v1.2.3