Safe Haskell | None |
---|
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- Miscellaneous polymorphic list-operations.
- type ChunkLength = Int
- chunk :: ChunkLength -> [a] -> [[a]]
- excise :: Int -> [a] -> [a]
- equalityBy :: Eq b => (a -> b) -> a -> a -> Bool
- findConvergence :: Eq a => [a] -> a
- findConvergenceBy :: (a -> a -> Bool) -> [a] -> a
- linearise :: [(a, a)] -> [a]
- merge :: Ord a => [a] -> [a] -> [a]
- mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
- nub' :: Ord a => [a] -> [a]
- permutations :: [[a]] -> [[a]]
- takeUntil :: (a -> Bool) -> [a] -> [a]
- showListWith :: (Show token, Show element) => (token, token, token) -> [element] -> ShowS
Types
Type-synonyms
type ChunkLength = IntSource
The length of the chunks into which a list is split.
Functions
:: ChunkLength | |
-> [a] | The polymorphic input list to be chunked. |
-> [[a]] |
- Splits a list into length-
size
pieces, where(size >= 0)
. - The last chunk will be shorter, if
n
isn't an aliquot part of the input list-length. - If
(size == 0)
, the resulting list will be an infinite sequence of null lists. - CAVEAT: a similar function is available in the module Data.List.Split, though this one checks for
(size < 0)
.
:: Int | The index. |
-> [a] | The polymorphic input list. |
-> [a] | The same list, with the indexed element removed. |
Remove the single indexed element from the list.
equalityBy :: Eq b => (a -> b) -> a -> a -> BoolSource
findConvergence :: Eq a => [a] -> aSource
A specific instance of findConvergenceBy
.
findConvergenceBy :: (a -> a -> Bool) -> [a] -> aSource
Take the first element from the list, which compares equal according to the specified predicate, with the subsequent element.
mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]Source
- Merge two sorted lists, according to the specified order, to product a single sorted list.
- The merge-process is stable, in that where items from each list are equal, they remain in the original order.
- CAVEAT: duplicates are preserved.
permutations :: [[a]] -> [[a]]Source
- The list of all permutations, generated by selecting any one datum from each sub-list in turn, from the specified list of lists.
- Taken from http://www.haskell.org/pipermail/haskell-cafe/2006-June/015975.html.
:: (a -> Bool) | Predicate, used to determine the last item taken. |
-> [a] | The polymorphic input list. |
-> [a] |
- Take until the specified predicate is satisfied; including the item which satisfied it.
- NB:
takeWhile (not . test)
would return one fewer item.