Skip to content

Commit e610796

Browse files
YilunAllenChenlpil
authored andcommitted
remove min
1 parent a3018d0 commit e610796

File tree

2 files changed

+0
-44
lines changed

2 files changed

+0
-44
lines changed

src/gleam/list.gleam

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,29 +2337,3 @@ pub fn max(
23372337
}
23382338
})
23392339
}
2340-
2341-
/// Takes a list and a comparator, and returns the minimum element in the list
2342-
///
2343-
///
2344-
/// ## Example
2345-
///
2346-
/// ```gleam
2347-
/// range(1, 10) |> list.int(int.compare)
2348-
/// // -> Ok(1)
2349-
/// ```
2350-
///
2351-
/// ```gleam
2352-
/// ["a", "c", "b"] |> list.int(string.compare)
2353-
/// // -> Ok("a")
2354-
/// ```
2355-
pub fn min(
2356-
over list: List(a),
2357-
with compare: fn(a, a) -> Order,
2358-
) -> Result(a, Nil) {
2359-
reduce(over: list, with: fn(acc, other) {
2360-
case compare(acc, other) {
2361-
order.Lt -> acc
2362-
_ -> other
2363-
}
2364-
})
2365-
}

test/gleam/list_test.gleam

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,21 +1299,3 @@ pub fn max_test() {
12991299
|> list.max(string.compare)
13001300
|> should.equal(Ok("c"))
13011301
}
1302-
1303-
pub fn min_test() {
1304-
[]
1305-
|> list.min(int.compare)
1306-
|> should.equal(Error(Nil))
1307-
1308-
[1, 3, 2]
1309-
|> list.min(int.compare)
1310-
|> should.equal(Ok(1))
1311-
1312-
[-1.0, 1.2, 1.104]
1313-
|> list.min(float.compare)
1314-
|> should.equal(Ok(-1.0))
1315-
1316-
["a", "c", "b"]
1317-
|> list.min(string.compare)
1318-
|> should.equal(Ok("a"))
1319-
}

0 commit comments

Comments
 (0)