gleam-lang / gleam-lang/stdlib
Add `list.min` function
- Dominant language
- Gleam
- Stars
- 710
- Forks
- 225
- Avg merge
- 5h 52m
- Merged PRs (30d)
- 3
Description
There is currently a `list.max` function in the stdlib, but not a `list.min` function.
This can lead to clunky code when `list.max` is used to retrieve the minimum value from a list.
```gleam
let min = list.max([1, 2, 3], order.reverse(int.compare))
```
I suggest also adding `list.min` to both avoid this clunkiness and make the stdlib less surprising (I was certainly surprised there was no `list.min` when there was a `list.max`). It seems a bit inconsistent to have a max and not a min, and is common in various other equivalent libraries that provide a max.
Rust [max](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.max) [min](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.min)
Erlang [max](https://www.erlang.org/docs/17/man/lists#max-1) [min](https://www.erlang.org/docs/17/man/lists#min-1)
Haskell [max](https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-List.html#v:maximum) [min](https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-List.html#v:minimum)
[There is a PR with a trivial implementation](https://github.com/gleam-lang/stdlib/pull/894).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.