minmax-0.1.1.0: Functions to find both minimum and maximum (or several of them simultaneously) in one pass.

Data.MinMax1

Description

Functions to find both minimum and maximum elements of the finite Foldable structure of the Ordered elements.

Synopsis

Documentation

minmaxP :: Ord a => a -> a -> (a, a) Source #

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.

minmaxPBy :: Ord a => (a -> a -> Ordering) -> a -> a -> (a, a) Source #

A variant of the minmaxP where you can specify your own comparison function.

betweenNX :: Ord a => a -> a -> a -> Bool Source #

A ternary predicate to check whether the third argument lies between the first two unequal ones or whether they are all equal.

betweenNXBy :: Ord a => (a -> a -> Ordering) -> a -> a -> a -> Bool Source #

A variant of the betweenNX where you can specify your own comparison function.

minMax11 :: (Ord a, Foldable t) => t a -> Maybe (a, a) Source #

Finds out the minimum and maximum values of the finite structure that has not less than two elements. Otherwise returns Nothing.

minMax11By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a) Source #

A generalized variant of the minMax11 where you can specify your own comparison function.

minMax21 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a) Source #

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.

minMax21By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a) Source #

A variant of the minMax21 where you can specify your own comparison function.

minMax12 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a) Source #

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.

minMax12By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a) Source #

A variant of the minMax12 where you can specify your own comparison function.

minMax22 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a, a) Source #

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.

minMax22By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a, a) Source #

A variant of the minMax22 where you can specify your own comparison function.