subG-0.4.0.0: Some extension to the Foldable and Monoid classes.
Copyright(c) OleksandrZhabenko 2020
LicenseMIT
Maintainerolexandr543@yahoo.com
StabilityExperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.MinMax.Preconditions

Description

Functions to find both minimum and maximum elements of the Foldable structure of the Ordered elements. With the preconditions that the structure at least have enough elements (this is contrary to the functions from the module Data.MinMax not checked internally).

Synopsis

Documentation

minMax11C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> (a, a) Source #

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

minMax11ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> (a, a) Source #

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

minMax21C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a), a) Source #

Given a finite structure returns a tuple with the two most minimum elements (the first one is less than the second one) and the maximum element. Uses just two passes through the structure, so may be more efficient than some other approaches.

minMax21ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a), a) Source #

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

minMax12C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> (a, (a, a)) Source #

Given a finite structure returns a tuple with the minimum element and two maximum elements (the first one is less than the second one). Uses just two passes through the structure, so may be more efficient than some other approaches.

minMax12ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> (a, (a, a)) Source #

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

minMax22C :: (Ord a, InsertLeft t a, Monoid (t a)) => t a -> ((a, a), (a, a)) Source #

Given a finite structure returns a tuple with two minimum elements and two maximum elements. Uses just two passes through the structure, so may be more efficient than some other approaches.

minMax22ByC :: (Ord a, InsertLeft t a, Monoid (t a)) => (a -> a -> Ordering) -> t a -> ((a, a), (a, a)) Source #

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