AUTHOR
- Dr. Alistair Ward
DESCRIPTION
- Miscellaneous polymorphic list-operations.
- type ChunkLength = Int
- chunk :: ChunkLength -> [a] -> [[a]]
- excise :: Int -> [a] -> [a]
- groupComparing :: Eq b => (a -> b) -> [a] -> [[a]]
- merge :: Ord a => [a] -> [a] -> [a]
- mergeBy :: Ord a => (a -> a -> Ordering) -> [a] -> [a] -> [a]
- splitsLeftFrom :: Int -> [a] -> [Split a]
- splitsRightFrom :: Int -> [a] -> [Split a]
- takeUntil :: (a -> Bool) -> [a] -> [a]
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.
:: Eq b | |
=> (a -> b) | Translates elements from the list, prior to testing the translated values for equality. |
-> [a] | The polymorphic input list to group. |
-> [[a]] | The same list split into chunks of the required length. |
- Much like
Data.List.GroupBy
, but where the normal binary predicate, is composed from equality, after the same unary translation-function has been applied to both list-elements. - cf.
GHC.Exts.groupWith
, which uses the function parameter to both sort and group.
merge :: Ord a => [a] -> [a] -> [a]Source
- Merge two sorted lists, 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.
mergeBy :: Ord a => (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.
:: Int | Index. |
-> [a] | The polymorphic input list from which the splits are generated, as the index is stepped left |
-> [Split a] | The list of all required splits of the single input list. |
:: Int | Index. |
-> [a] | The polymorphic input list from which the splits are generated, as the index is stepped right. |
-> [Split a] | The list of all required splits of the single input list. |
- Create the set of all
Split
s, migrating right from the specified location. - CAVEAT: pattern-match against
:
fails, whensnd
has been reduced to null.