Safe Haskell | None |
---|---|
Language | Haskell2010 |
AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- Miscellaneous polymorphic list-operations.
- type ChunkLength = Int
- type Matches a = a -> a -> Bool
- chunk :: ChunkLength -> [a] -> [[a]]
- excise :: Int -> [a] -> [a]
- equalityBy :: Eq b => (a -> b) -> Matches a
- findConvergence :: Eq a => [a] -> a
- findConvergenceBy :: Matches a -> [a] -> a
- interleave :: [a] -> [a] -> [a]
- linearise :: [(a, a)] -> [a]
- measureJaroDistance :: (Eq a, Fractional distance) => ([a], [a]) -> distance
- merge :: Ord a => [a] -> [a] -> [a]
- mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
- nub' :: Ord a => [a] -> [a]
- permutations :: [[a]] -> [[a]]
- permutationsBy :: Matches a -> [[a]] -> [[a]]
- takeUntil :: (a -> Bool) -> [a] -> [a]
- showListWith :: (Show token, Show element) => (token, token, token) -> [element] -> ShowS
Types
Type-synonyms
type ChunkLength = Int Source #
The length of the chunks into which a list is split.
type Matches a = a -> a -> Bool Source #
The type of function required by findConvergenceBy
, permutationsBy
.
Functions
:: ChunkLength | |
-> [a] | The polymorphic input list to be chunked. |
-> [[a]] |
- Splits a list into chunks of the specified length.
- The last chunk will be shorter, if the chunk-length isn't an aliquot part of the input list-length.
- If the chunk-length is zero, 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
(chunkLength < 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) -> Matches a Source #
A convenient way to compose the Matches
-function required by findConvergenceBy
& permutationsBy
.
findConvergence :: Eq a => [a] -> a Source #
A specific instance of findConvergenceBy
.
findConvergenceBy :: Matches a -> [a] -> a Source #
Take the first element from the (potentially infinite) list, which matches the subsequent element, according to the specified function.
interleave :: [a] -> [a] -> [a] Source #
Interleaves the specified lists, taking the first item from the first list.
measureJaroDistance :: (Eq a, Fractional distance) => ([a], [a]) -> distance Source #
- Measures the distance between two lists (typically Strings).
- The operation is commutative; it doesn't matter about the order of the arguments.
- The result ranges from 0 when they're completely dissimilar, to 1 when identical.
- https://lingpipe-blog.com/2006/12/13/code-spelunking-jaro-winkler-string-comparison.
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.
- A specific instance of
permutationsBy
, in which no filtering of subsequent lists is performed after each item is selected. - N.B.: differs from
permutations
, which selects items from a single input list.
permutationsBy :: Matches a -> [[a]] -> [[a]] Source #
:: (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.
- N.B.:
takeWhile (not . test)
would return one fewer item.