Skip to content

minimumOn function #331

@Boarders

Description

@Boarders

It would be nice to have a minimumOn function of the form:

minimumOn :: (Ord b, Generic.Vector v a) => (a -> b) -> v a -> a 

A possible implementation could just adapt the existing one for minimumBy:

minimumOn :: (Ord b, Vector v a) => (a -> b) -> v a -> a
{-# INLINE minimumOn #-}
minimumOn f = Bundle.foldl1' minBy . stream
  where
    {-# INLINE minBy #-}
    minBy x y = case compare (f x) (f y) of
                  GT -> y
                  _  -> x

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