rosso-1.0: General purpose utility library



Extends Data.List



module Data.List

dropEachElem :: [a] -> [[a]]Source

Returns a list of lists, each obtained by dropping a single element of the argument.

>>> dropEachElem "abcd"

extractEachElem :: [a] -> [(a, [a])]Source

Similar to dropEachElem, but each output list is paired with the element that was dropped.

>>> extractEachElem "abcd"

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]

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')]

zipFilter :: [Bool] -> [a] -> [a]Source

Filters a list of values according to a list of corresponding boolean flags.

>>> zipFilter [False, True, False, True, True] [0..]