Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- leaveOutOne :: [a] -> [(a, [a])]
- minimum1 :: Ord a => [a] -> Maybe a
- maximum1 :: Ord a => [a] -> Maybe a
- minimum1By :: (a -> a -> Ordering) -> [a] -> Maybe a
- minimaOn :: Ord b => (a -> b) -> [a] -> [a]
- minimaBy :: (a -> a -> Ordering) -> [a] -> [a]
- extractMinimaBy :: (a -> a -> Ordering) -> [a] -> [a] :+ [a]
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
minimum1By :: (a -> a -> Ordering) -> [a] -> Maybe a Source #
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]