Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Miscellaneous functions for manipulating lists.
- hasSubset :: Eq a => [a] -> [a] -> Bool
- disjoint :: Eq a => [a] -> [a] -> Bool
- replaceByFst :: Eq a => (a, b) -> [(a, b)] -> [(a, b)]
- noDuplicates :: Eq a => [a] -> Bool
- sameElements :: Ord a => [a] -> [a] -> Bool
- notDuplicatedIn :: Eq b => (a -> b) -> a -> [a] -> Bool
- deleteOn :: Eq b => (a -> b) -> a -> [a] -> [a]
- maybeList :: [a] -> Maybe [a]
- elemPermutation :: Eq a => [a] -> [a] -> Maybe [Int]
- groupOn :: Eq b => (a -> b) -> [a] -> [[a]]
- nubOn :: Eq b => (a -> b) -> [a] -> [a]
- sortOn :: Ord b => (a -> b) -> [a] -> [a]
- sortedGroups :: Ord b => [(b, c)] -> [(b, [c])]
- sortedGroupsOn :: Ord b => (a -> b) -> (a -> c) -> [a] -> [(b, [c])]
- regroup :: Ord a => [(a, b)] -> [(a, [b])]
- regroupBy :: Ord a => ([b] -> c) -> [(a, b)] -> [(a, c)]
- domain :: (Bounded a, Enum a) => [a]
- powerSet :: [a] -> [[a]]
- powerSetPermutations :: [a] -> [[a]]
- uniquePowerSetPermutations :: Eq a => [a] -> [[a]]
- suffixes :: [a] -> [[a]]
- nest :: Monad m => [a] -> [m a]
- map2 :: (a -> b) -> [[a]] -> [[b]]
- zipf :: [a -> b] -> [a] -> [b]
- lookupWithDefault :: Eq a => b -> a -> [(a, b)] -> b
- lookupWithDefaultFunction :: Eq a => (a -> b) -> a -> [(a, b)] -> b
- replicateHead :: Int -> [a] -> [a]
- padHead :: Int -> a -> [a] -> [a]
- padTail :: Int -> a -> [a] -> [a]
- chunk :: Int -> [a] -> [[a]]
- stripHead :: Eq a => a -> [a] -> [a]
- discardEnds :: [a] -> [a]
- removeDuplicates :: Eq a => [a] -> [a]
- removeDuplicatesBy :: (a -> a -> Bool) -> [a] -> [a]
- extract :: (a -> Bool) -> [a] -> ([a], Maybe a)
- rollback :: [a] -> [a] -> [a]
- splitAtMatches :: Eq a => a -> [a] -> [[a]]
- splitAround :: Int -> [a] -> ([a], a, [a])
Subsets
:: Eq a | |
=> [a] | The potential superset. |
-> [a] | The potential subset |
-> Bool | Whether the first set has the second as a subset. |
Test for containment.
Test for disjointness.
:: Eq a | |
=> (a, b) | The replacement key and value. |
-> [(a, b)] | The lookup table. |
-> [(a, b)] | The updated table. |
Replace the first occurrence in a lookup table.
Test for duplicates.
:: Ord a | |
=> [a] | The first list. |
-> [a] | The second list. |
-> Bool | Whether the lists have the same elements. |
Test for same elements.
:: Eq b | |
=> (a -> b) | The equality test. |
-> a | The value. |
-> [a] | The list. |
-> Bool | Whether the value is in the list. |
Test for membership of an element in a list.
Permutations
elemPermutation :: Eq a => [a] -> [a] -> Maybe [Int] Source #
Find the permutation of one list relative to another.
Grouping and sorting
sortedGroups :: Ord b => [(b, c)] -> [(b, [c])] Source #
Sort and group.
sortedGroupsOn :: Ord b => (a -> b) -> (a -> c) -> [a] -> [(b, [c])] Source #
Sort and group using a function to extract values.
regroup :: Ord a => [(a, b)] -> [(a, [b])] Source #
Sort and regroup elements of an association using its keys.
:: Ord a | |
=> ([b] -> c) | The function for summarizing the second element of pairs. |
-> [(a, b)] | The associations. |
-> [(a, c)] | The regrouped associations. |
Sort and regroup elements of an association using its keys.
Bounded enumerations.
Permutations.
powerSet :: [a] -> [[a]] Source #
Generate a power set. The algorithm used here is from http://evan-tech.livejournal.com/220036.html.
powerSetPermutations :: [a] -> [[a]] Source #
Generate a power set's permutations.
uniquePowerSetPermutations :: Eq a => [a] -> [[a]] Source #
Generate a power set's unique permutations.
Monads.
Mapping.
:: [a -> b] | The list of functions to be applied |
-> [a] | The list of elements to which the functions will be applied |
-> [b] | The result of the function applications |
The zipf
function applies a list of functions to corresponding elements in a list.
Lookups.
:: Eq a | |
=> b | The default value. |
-> a | The key. |
-> [(a, b)] | The associations. |
-> b | The value for the key, or the default if the key is not present. |
Look up a value in an association list.
lookupWithDefaultFunction Source #
:: Eq a | |
=> (a -> b) | The function for generating the default value. |
-> a | The key. |
-> [(a, b)] | The associations. |
-> b | The value for the key, or the default if the key is not present. |
Look up a value in an association list.
Padding, stripping, and pruning.
:: Int | Number of times to replicate the head. |
-> [a] | The list. |
-> [a] | The list with the replicas of the head. |
Relicating the head of a list.
:: Int | Length of result. |
-> a | Item to use for padding. |
-> [a] | The list. |
-> [a] | The padded list. |
Pad the head of a list.
:: Int | Length of the result. |
-> a | Item to use for padding. |
-> [a] | The list. |
-> [a] | THe padded list. |
Pad the tail of a list.
:: Int | Length of the chunks. |
-> [a] | The list. |
-> [[a]] | The chunked list. |
Deprecated: Use chunksOf
instead.
Break a list into equally sized chunks.
:: Eq a | |
=> a | The item to remove from the start of list. |
-> [a] | The list. |
-> [a] | The list without the leading items. |
Remove leading items from a list.
:: [a] | The list |
-> [a] | The interior of the list |
The discard
function removes the first and last elements from a list.
removeDuplicates :: Eq a => [a] -> [a] Source #
Remove duplicates from a list, maintaining its order.
:: (a -> a -> Bool) | Equality test function. |
-> [a] | The list. |
-> [a] | The list with duplicates removed. |
Remove duplicates from a list, maintaining its order.
:: [a] | The list to be reversed and prepended. |
-> [a] | The list to be appended. |
-> [a] | The resulting list |
Reverse a first list and add it to a second one.
Splitting.
:: Eq a | |
=> a | The separatrix. |
-> [a] | The list. |
-> [[a]] | The split list. |
Deprecated: Use wordsBy
instead.
Split up a list at every match of a particular item.
splitAround :: Int -> [a] -> ([a], a, [a]) Source #
Split a list around a particular element.