-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Functions to find both minimum and maximum (or several of them simultaneously) in one pass. -- -- Contains some functions to find out both minimum and maximum elements -- of the finite Foldable structures in one pass. Is a fork of the -- https://hackage.haskell.org/package/subG-0.6.1.0. @package minmax @version 0.1.0.0 -- | Functions to find both minimum and maximum elements of the finite -- Foldable structure of the Ordered elements. module Data.MinMax1 -- | Returns a pair where the first element is the minimum element from the -- two given ones and the second one is the maximum. If the arguments are -- equal then the tuple contains equal elements. minmaxP :: Ord a => a -> a -> (a, a) -- | A variant of the minmaxP where you can specify your own -- comparison function. minmaxPBy :: Ord a => (a -> a -> Ordering) -> a -> a -> (a, a) -- | A ternary predicate to check whether the third argument lies between -- the first two unequal ones or whether they are all equal. betweenNX :: Ord a => a -> a -> a -> Bool -- | A variant of the betweenNX where you can specify your own -- comparison function. betweenNXBy :: Ord a => (a -> a -> Ordering) -> a -> a -> a -> Bool -- | Finds out the minimum and maximum values of the finite structure that -- has not less than two elements. Otherwise returns Nothing. minMax11 :: (Ord a, Foldable t) => t a -> Maybe (a, a) -- | A generalized variant of the minMax11 where you can specify -- your own comparison function. minMax11By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a) -- | Given a finite structure with at least 3 elements returns a tuple with -- the two most minimum elements (the first one is less than the second -- one) and the maximum element. If the structure has less elements, -- returns Nothing. Uses just one pass through the structure, so -- may be more efficient than some other approaches. minMax21 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a) -- | A variant of the minMax21 where you can specify your own -- comparison function. minMax21By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a) -- | Given a finite structure with at least 3 elements returns a tuple with -- the minimum element and two maximum elements (the first one is less -- than the second one). If the structure has less elements, returns -- Nothing. Uses just one pass through the structure, so may be -- more efficient than some other approaches. minMax12 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a) -- | A variant of the minMax12 where you can specify your own -- comparison function. minMax12By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a) -- | Given a finite structure with at least 4 elements returns a tuple with -- two minimum elements and two maximum elements. If the structure has -- less elements, returns Nothing. Uses just one pass through the -- structure, so may be more efficient than some other approaches. minMax22 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a, a) -- | A variant of the minMax22 where you can specify your own -- comparison function. minMax22By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a, a)