Copyright | Copyright (c) 2007--2021 wren gayle romano |
---|---|
License | BSD3 |
Maintainer | wren@cpan.org |
Stability | experimental |
Portability | Haskell98 |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- 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 b Source #
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] -> a Source #
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] -> a Source #
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] -> a Source #
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.