Skip to content

Add maximum, maximumBy, minimum, minimumBy #9

@sharkdp

Description

@sharkdp

What about adding small wrappers for the Foldable functions maximum, maximumBy, minimum, minimumBy? For NonEmpty, the return type could be a instead of Maybe a:

import Data.Foldable as F

...

-- | Find the smallest element of a non-empty structure, according to its `Ord`
-- | instance.
minimum :: forall a f. (Ord a, Foldable f) => NonEmpty f a -> a
minimum xs@(NonEmpty x _) = fromMaybe x (F.minimum xs)

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