diff --git a/src/gleam_community/complex.gleam b/src/gleam_community/complex.gleam index 994f0a7..2642794 100644 --- a/src/gleam_community/complex.gleam +++ b/src/gleam_community/complex.gleam @@ -1,7 +1,6 @@ import gleam/bool import gleam/float import gleam/int -import gleam/io import gleam/list import gleam/order.{type Order, Eq, Gt, Lt} import gleam/result @@ -89,7 +88,7 @@ pub fn power(z: Complex, n: Int) -> Result(Complex, Nil) { // 0 ^ n -> 0 Error(_), _ -> Ok(Complex(0.0, 0.0)) // z ^ 0 -> 1 - Ok(_), Eq -> Ok(multiplicative_identify()) + Ok(_), Eq -> Ok(multiplicative_identity()) // De Moivre's Theorem only works for positive integers Ok(_), Lt -> Error(Nil) Ok(arg), _ -> { @@ -137,7 +136,7 @@ fn zero() -> Complex { Complex(0.0, 0.0) } -fn multiplicative_identify() -> Complex { +fn multiplicative_identity() -> Complex { from_float(1.0) } @@ -146,7 +145,7 @@ pub fn sum(arr: List(Complex)) -> Complex { } pub fn product(arr: List(Complex)) -> Complex { - list.fold(arr, multiplicative_identify(), multiply) + list.fold(arr, multiplicative_identity(), multiply) } pub fn weighted_sum(arr: List(#(Complex, Float))) -> Result(Complex, Nil) { @@ -167,7 +166,7 @@ pub fn weighted_product(arr: List(#(Complex, Int))) -> Result(Complex, Nil) { case weight_is_negative { True -> Error(Nil) False -> - list.fold(arr, Ok(multiplicative_identify()), fn(acc_result, tuple) { + list.fold(arr, Ok(multiplicative_identity()), fn(acc_result, tuple) { acc_result |> result.then(fn(acc) { power(tuple.0, tuple.1) @@ -182,7 +181,7 @@ pub fn cumulative_sum(arr: List(Complex)) -> List(Complex) { } pub fn cumulative_product(arr: List(Complex)) -> List(Complex) { - list.scan(arr, multiplicative_identify(), multiply) + list.scan(arr, multiplicative_identity(), multiply) } pub fn absolute_difference(a: Complex, b: Complex) { diff --git a/test/gleam_community/complex_test.gleam b/test/gleam_community/complex_test.gleam index a84c259..1a8778c 100644 --- a/test/gleam_community/complex_test.gleam +++ b/test/gleam_community/complex_test.gleam @@ -1,6 +1,5 @@ import gleam/float import gleam/function -import gleam/io import gleam/list import gleam/order.{Eq, Gt, Lt} import gleam_community/complex.{Complex}