Skip to content

Add list.min function #895

@Eosis

Description

@Eosis

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.

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 min
Erlang max min
Haskell max min

There is a PR with a trivial implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions