Portability | portable |
---|---|

Stability | experimental |

Maintainer | wren@community.haskell.org |

- catchNull :: ([a] -> b) -> [a] -> Maybe b
- argmaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> a
- argmaxesBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> [a]
- argmaxWithMaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> (a, b)
- argmaxesWithMaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> ([a], b)
- argmax :: Ord b => (a -> b) -> [a] -> a
- argmaxes :: Ord b => (a -> b) -> [a] -> [a]
- argmaxWithMax :: Ord b => (a -> b) -> [a] -> (a, b)
- argmaxesWithMax :: Ord b => (a -> b) -> [a] -> ([a], b)
- argmin :: Ord b => (a -> b) -> [a] -> a
- argmins :: Ord b => (a -> b) -> [a] -> [a]
- argminWithMin :: Ord b => (a -> b) -> [a] -> (a, b)
- argminsWithMin :: Ord b => (a -> b) -> [a] -> ([a], b)

# Utility functions

catchNull :: ([a] -> b) -> [a] -> Maybe bSource

Apply a list function safely, i.e. when the list is non-empty. All other functions will throw errors on empty lists, so use this to make your own safe variations.

# Generic versions

argmaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> aSource

Return an element of the list which maximizes the function according to a user-defined ordering.

argmaxesBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> [a]Source

Return all elements of the list which maximize the function according to a user-defined ordering.

argmaxWithMaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> (a, b)Source

Return an element of the list which maximizes the function according to a user-defined ordering, and return the value of the function at that element as well.

argmaxesWithMaxBy :: (b -> b -> Ordering) -> (a -> b) -> [a] -> ([a], b)Source

Return all elements of the list which maximize the function according to a user-defined ordering, and return the value of the function at those elements as well.

# Maximum variations

argmax :: Ord b => (a -> b) -> [a] -> aSource

Return an element of the list which maximizes the function.

argmaxes :: Ord b => (a -> b) -> [a] -> [a]Source

Return all elements of the list which maximize the function.

argmaxWithMax :: Ord b => (a -> b) -> [a] -> (a, b)Source

Return an element of the list which maximizes the function, and return the value of the function at that element as well.

argmaxesWithMax :: Ord b => (a -> b) -> [a] -> ([a], b)Source

Return all elements of the list which maximize the function, and return the value of the function at those elements as well.

# Minimum variations

argmin :: Ord b => (a -> b) -> [a] -> aSource

Return an element of the list which minimizes the function.

argmins :: Ord b => (a -> b) -> [a] -> [a]Source

Return all elements of the list which minimize the function.

argminWithMin :: Ord b => (a -> b) -> [a] -> (a, b)Source

Return an element of the list which minimizes the function, and return the value of the function at that element as well.

argminsWithMin :: Ord b => (a -> b) -> [a] -> ([a], b)Source

Return all elements of the list which minimize the function, and return the value of the function at those elements as well.