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

Data.MinMax3Plus

Description

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

Synopsis

Documentation

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

Given a finite structure with at least 5 elements returns a tuple with two minimum elements and three maximum elements. If the structure has less elements, returns Nothing. Uses just three passes through the structure, so may be more efficient than some other approaches.

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

Given a finite structure with at least 5 elements returns a tuple with three minimum elements and two maximum elements. If the structure has less elements, returns Nothing. Uses just three passes through the structure, so may be more efficient than some other approaches.

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

Given a finite structure with at least 6 elements returns a tuple with three minimum elements and three maximum elements. If the structure has less elements, returns Nothing. Uses just three passes through the structure, so may be more efficient than some other approaches.