hgeometry-combinatorial-0.11.0.0: Data structures, and Data types.

Safe HaskellNone
LanguageHaskell2010

Data.List.Util

Contents

Synopsis

Documentation

leaveOutOne :: [a] -> [(a, [a])] Source #

Given an input list, computes all lists in which just one element is missing.

>>> mapM_ print $ leaveOutOne [1..5]
(1,[2,3,4,5])
(2,[1,3,4,5])
(3,[1,2,4,5])
(4,[1,2,3,5])
(5,[1,2,3,4])
>>> leaveOutOne []
[]
>>> leaveOutOne [1]
[(1,[])]

Improved functions for minima and maxima

minimum1 :: Ord a => [a] -> Maybe a Source #

maximum1 :: Ord a => [a] -> Maybe a Source #

minimum1By :: (a -> a -> Ordering) -> [a] -> Maybe a Source #

minimaOn :: Ord b => (a -> b) -> [a] -> [a] Source #

minimaBy :: (a -> a -> Ordering) -> [a] -> [a] Source #

computes all minima

extractMinimaBy :: (a -> a -> Ordering) -> [a] -> [a] :+ [a] Source #

extracts all minima from the list. The result consists of the list of minima, and all remaining points. Both lists are returned in the order in which they occur in the input.

>>> extractMinimaBy compare [1,2,3,0,1,2,3,0,1,2,0,2]
[0,0,0] :+ [2,3,1,2,3,1,2,1,2]