keep every k-th value from the list
Since these implementations check for the end of lists,
they may fail in fixpoint computations on infinite lists.
|Use lists as counters
|takeMatch :: [b] -> [a] -> [a]||Source|
|Make a list as long as another one
|splitAtMatch :: [b] -> [a] -> ([a], [a])||Source|
|replicateMatch :: [a] -> b -> [b]||Source|
|Compare the length of two lists over different types.
For finite lists it is equivalent to (compare (length xs) (length ys))
but more efficient.
|=> a||function applied to corresponding elements of the lists
|-> a -> a -> b|
|zip two lists using an arbitrary function, the shorter list is padded
|zipWithOverlap :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c]||Source|
|=> a -> b -> c|
|Zip two lists which must be of the same length.
This is checked only lazily, that is unequal lengths are detected only
if the list is evaluated completely.
But it is more strict than zipWithPad undefined f
since the latter one may succeed on unequal length list if f is lazy.
|zipNeighborsWith :: (a -> a -> a) -> [a] -> [a]||Source|
|Lists of lists
[10,11,12,...], --> [10,01],
With concat . shear you can perform a Cantor diagonalization,
that is an enumeration of all elements of the sub-lists
where each element is reachable within a finite number of steps.
It is also useful for polynomial multiplication (convolution).
|shearTranspose :: [[a]] -> [[a]]||Source|
[10,11,12,...], --> [01,10],
It's like shear but the order of elements in the sub list is reversed.
Its implementation seems to be more efficient than that of shear.
If the order does not matter, better choose shearTranspose.
|outerProduct :: (a -> b -> c) -> [a] -> [b] -> [[c]]||Source|
|Operate on each combination of elements of the first and the second list.
In contrast to the list instance of Monad.liftM2
in holds the results in a list of lists.
concat (outerProduct f xs ys) == liftM2 f xs ys
|partitionMaybe :: (a -> Maybe b) -> [a] -> ([b], [a])||Source|
|splitLast :: [a] -> ([a], a)||Source|
|It holds splitLast xs == (init xs, last xs),
but splitLast is more efficient
if the last element is accessed after the initial ones,
because it avoids memoizing list.
|Remove the longest suffix of elements satisfying p.
In contrast to 'reverse . dropWhile p . reverse'
this works for infinite lists, too.
|mapLast :: (a -> a) -> [a] -> [a]||Source|
|Apply a function to the last element of a list.
If the list is empty, nothing changes.
|reduceRepeatedSlow :: (a -> a -> a) -> a -> a -> Integer -> a||Source|
reduceRepeated is an auxiliary function that,
for an associative operation op,
computes the same value as
reduceRepeated op a0 a n = foldr op a0 (genericReplicate n a)
but applies op O(log n) times and works for large n.
|iterateLeaky :: (a -> a -> a) -> a -> [a]||Source|
For an associative operation op this computes
iterateAssoc op a = iterate (op a) a
but it is even faster than map (reduceRepeated op a a) [0..]
since it shares temporary results.
The idea is:
From the list map (reduceRepeated op a a) [0,(2*n)..]
we compute the list map (reduceRepeated op a a) [0,n..],
and iterate that until n==1.
|iterateAssoc :: (a -> a -> a) -> a -> [a]||Source|
|Produced by Haddock version 2.6.0|