list-extras-0.1.1: Common not-so-common functions for listsSource codeContentsIndex
Data.List.Extras.ArgMax
Portabilityportable
Stabilityexperimental
Maintainerwren@community.haskell.org
Contents
Maximum variations
Minimum variations
Generic versions
Description
This module provides variants of the maximum and minimum functions which return the element for which some function is maximized or minimized.
Synopsis
argmax :: Ord b => (a -> b) -> [a] -> Maybe a
argmax' :: Ord b => (a -> b) -> [a] -> a
argmin :: Ord b => (a -> b) -> [a] -> Maybe a
argmin' :: Ord b => (a -> b) -> [a] -> a
argmaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> Maybe a
argmaxBy' :: (b -> b -> Ordering) -> (a -> b) -> [a] -> a
Maximum variations
argmax :: Ord b => (a -> b) -> [a] -> Maybe aSource
Returns the element of the list which maximizes the function, or Nothing if the list was empty.
argmax' :: Ord b => (a -> b) -> [a] -> aSource
Direct version of argmax which doesn't catch the empty list error.
Minimum variations
argmin :: Ord b => (a -> b) -> [a] -> Maybe aSource
Returns the element of the list which minimizes the function, or Nothing if the list was empty.
argmin' :: Ord b => (a -> b) -> [a] -> aSource
Direct version of argmin which doesn't catch the empty list error.
Generic versions
argmaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> Maybe aSource
Returns the element of the list which maximizes a function according to a user-defined ordering, or Nothing if the list was empty.
argmaxBy' :: (b -> b -> Ordering) -> (a -> b) -> [a] -> aSource
Direct version of argmaxBy which doesn't catch the empty list error.
Produced by Haddock version 2.3.0