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.

`>>>`

["bcd","acd","abd","abc"]`dropEachElem "abcd"`

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

Similar to `dropEachElem`

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

`>>>`

[('a',"bcd"),('b',"acd"),('c',"abd"),('d',"abc")]`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.

`>>>`

[[3,6,9],[1,4,7,10],[2,5,8]]`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.

`>>>`

[(3,"aab"),(5,"x"),(7,"a")]`alistCollect [(7, 'a'), (3, 'a'), (5, 'x'), (3, 'a'), (3, 'b')]`