Data.List.Rosso1
Description
Extends Data.List
- module Data.List
- dropEachElem :: [a] -> [[a]]
- extractEachElem :: [a] -> [(a, [a])]
- sortAndGroupOn :: Ord b => (a -> b) -> [a] -> [[a]]
- alistCollect :: Ord k => [(k, a)] -> [(k, [a])]
- zipFilter :: [Bool] -> [a] -> [a]
Documentation
module Data.List
dropEachElem :: [a] -> [[a]]Source
Returns a list of lists, each obtained by dropping a single element of the argument.
>>>
dropEachElem "abcd"
["bcd","acd","abd","abc"]
extractEachElem :: [a] -> [(a, [a])]Source
Similar to dropEachElem
, but each output list is paired with the
element that was dropped.
>>>
extractEachElem "abcd"
[('a',"bcd"),('b',"acd"),('c',"abd"),('d',"abc")]
sortAndGroupOn :: Ord b => (a -> b) -> [a] -> [[a]]Source
Sorts, then groups the elements of a list, using a specified key function. The sorting process is stable, i.e. elements with equal keys remain in the same order.
>>>
sortAndGroupOn (`mod` 3) [1..10]
[[3,6,9],[1,4,7,10],[2,5,8]]
alistCollect :: Ord k => [(k, a)] -> [(k, [a])]Source
Collects together the list of values corresponding to each unique key in an association list. Entries in the output list are arranged in ascending order of key. The ordering of values corresponding to a given key is preserved from input to output.
>>>
alistCollect [(7, 'a'), (3, 'a'), (5, 'x'), (3, 'a'), (3, 'b')]
[(3,"aab"),(5,"x"),(7,"a")]