Copyright | (c) OleksandrZhabenko 2020-2024 |
---|---|

License | MIT |

Maintainer | oleksandr.zhabenko@yahoo.com |

Stability | Experimental |

Safe Haskell | None |

Language | Haskell2010 |

## Synopsis

- minmaxP :: Ord a => a -> a -> (a, a)
- minmaxPBy :: Ord a => (a -> a -> Ordering) -> a -> a -> (a, a)
- betweenNX :: Ord a => a -> a -> a -> Bool
- betweenNXBy :: Ord a => (a -> a -> Ordering) -> a -> a -> a -> Bool
- minMax11 :: (Ord a, Foldable t) => t a -> Maybe (a, a)
- minMax11By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a)
- minMax21 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a)
- minMax21By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a)
- minMax12 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a)
- minMax12By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a)
- minMax22 :: (Ord a, Foldable t) => t a -> Maybe (a, a, a, a)
- minMax22By :: (Ord a, Foldable t) => (a -> a -> Ordering) -> t a -> Maybe (a, a, a, a)

# 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.