diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index 2d5b624e..6c41df0e 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -2337,29 +2337,3 @@ pub fn max( } }) } - -/// Takes a list and a comparator, and returns the minimum element in the list -/// -/// -/// ## Example -/// -/// ```gleam -/// range(1, 10) |> list.int(int.compare) -/// // -> Ok(1) -/// ``` -/// -/// ```gleam -/// ["a", "c", "b"] |> list.int(string.compare) -/// // -> Ok("a") -/// ``` -pub fn min( - over list: List(a), - with compare: fn(a, a) -> Order, -) -> Result(a, Nil) { - reduce(over: list, with: fn(acc, other) { - case compare(acc, other) { - order.Lt -> acc - _ -> other - } - }) -} diff --git a/test/gleam/list_test.gleam b/test/gleam/list_test.gleam index 0e7e4dee..2a67f949 100644 --- a/test/gleam/list_test.gleam +++ b/test/gleam/list_test.gleam @@ -1299,21 +1299,3 @@ pub fn max_test() { |> list.max(string.compare) |> should.equal(Ok("c")) } - -pub fn min_test() { - [] - |> list.min(int.compare) - |> should.equal(Error(Nil)) - - [1, 3, 2] - |> list.min(int.compare) - |> should.equal(Ok(1)) - - [-1.0, 1.2, 1.104] - |> list.min(float.compare) - |> should.equal(Ok(-1.0)) - - ["a", "c", "b"] - |> list.min(string.compare) - |> should.equal(Ok("a")) -}