sr-extra-1.46.3.2: A grab bag of modules.

Safe HaskellSafe
LanguageHaskell98

Extra.List

Synopsis

Documentation

consperse :: [a] -> [[a]] -> [a] Source

Deprecated: Use intercalate

The mighty consperse function - e.g. consperse "," ["a", "b"] -> "a,b" consperse = MissingH.List.join

surround :: [a] -> [a] -> [[a]] -> [a] Source

surround each element of a list - e.g. surround "(" ")" ["a", "b"] -> ["(a)(b)"]

changePrefix :: Eq a => [a] -> [a] -> [a] -> Maybe [a] Source

Replace the prefix of s, return Nothing if it doesn't match.

dropPrefix :: Eq a => [a] -> [a] -> Maybe [a] Source

Remove a prefix of s, return nothing if it doesn't match.

cartesianProduct :: [[a]] -> [[a]] Source

cartesianProduct [[1,2,3], [4,5],[6]] -> [[1,4,6],[1,5,6],[2,4,6],[2,5,6],[3,4,6],[3,5,6]]

wordsBy :: Eq a => (a -> Bool) -> [a] -> [[a]] Source

FIXME: implement for a string

empty :: b -> ([a] -> b) -> [a] -> b Source

Like maybe, but with empty vs. non-empty list

sortByMapped :: (a -> b) -> (b -> b -> Ordering) -> [a] -> [a] Source

Sort a list using the compare function on the list elements mapped over f. This is like "sortBy ( a b -> compare (f a) (f b))" except that f is applied O(n) times instead of O(n log n)

sortByMappedM :: (a -> IO b) -> (b -> b -> Ordering) -> [a] -> IO [a] Source

Monadic version of sortByMapped

partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a]) Source

listIntersection :: Eq a => [[a]] -> [a] Source

isSublistOf :: Eq a => [a] -> [a] -> Maybe Int Source