hask.Data.List – The Data.List

hask.Data.List.head(*args, **kwargs)

head :: [a] -> a

Extract the first element of a list, which must be non-empty.

hask.Data.List.last(*args, **kwargs)

last :: [a] -> a

Extract the last element of a list, which must be finite and non-empty.

hask.Data.List.tail(*args, **kwargs)

tail :: [a] -> [a]

Extract the elements after the head of a list, which must be non-empty.

hask.Data.List.init(*args, **kwargs)

init :: [a] -> [a]

Return all the elements of a list except the last one. The list must be non-empty.

hask.Data.List.uncons(*args, **kwargs)

uncons :: [a] -> Maybe (a, [a])

Decompose a list into its head and tail. If the list is empty, returns Nothing. If the list is non-empty, returns Just((x, xs)), where x is the head of the list and xs its tail.

hask.Data.List.null(*args, **kwargs)

null :: [a] -> bool

Test whether the structure is empty.

hask.Data.List.length(*args, **kwargs)

length :: [a] -> int

Returns the size/length of a finite structure as an Int. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

hask.Data.List.map(*args, **kwargs)

map :: (a -> b) -> [a] -> [b]

map(f, xs) is the list obtained by applying f to each element of xs

hask.Data.List.reverse(*args, **kwargs)

reverse :: [a] -> [a]

reverse(xs) returns the elements of xs in reverse order. xs must be finite.

hask.Data.List.intersperse(*args, **kwargs)

intersperse :: a -> [a] -> [a]

The intersperse function takes an element and a list and intersperses that element between the elements of the list.

hask.Data.List.intercalate(*args, **kwargs)

intercalate :: [a] -> [[a]] -> [a]

intercalate(xs,xss) is equivalent to concat(intersperse(xs,xss)). It inserts the list xs in between the lists in xss and concatenates the result.

hask.Data.List.transpose(*args, **kwargs)

transpose :: [[a]] -> [[a]]

The transpose function transposes the rows and columns of its argument.

hask.Data.List.subsequences(*args, **kwargs)

subsequences :: [a] -> [[a]]

The subsequences function returns the list of all subsequences of the argument.

hask.Data.List.permutations(*args, **kwargs)

permutations :: [a] -> [[a]]

The permutations function returns the list of all permutations of the argument.

hask.Data.List.foldl(*args, **kwargs)

foldl :: (b -> a -> b) -> b -> [a] -> b

foldl, applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right. The list must be finite.

hask.Data.List.foldl_(*args, **kwargs)

foldl_ :: (b -> a -> b) -> b -> [a] -> b

A strict version of foldl.

hask.Data.List.foldl1(*args, **kwargs)

foldl1 :: (a -> a -> a) -> [a] -> a

foldl1 is a variant of foldl that has no starting value argument, and thus must be applied to non-empty lists.

hask.Data.List.foldl1_(*args, **kwargs)

foldl1_ :: (a -> a -> a) -> [a] -> a

A strict version of foldl1

hask.Data.List.foldr(*args, **kwargs)

foldr :: (a -> b -> b) -> b -> [a] -> b

foldr, applied to a binary operator, a starting value (typically the right-identity of the operator), and a list, reduces the list using the binary operator, from right to left

hask.Data.List.foldr1(*args, **kwargs)

foldr1 :: (a -> a -> a) -> [a] -> a

foldr1 is a variant of foldr that has no starting value argument, and thus must be applied to non-empty lists.

hask.Data.List.concat(*args, **kwargs)

concat :: [[a]] -> [a]

Concatenate a list of lists.

hask.Data.List.concatMap(*args, **kwargs)

concatMap :: (a -> [b]) -> [a] -> [b]

Map a function over a list and concatenate the results.

hask.Data.List.and_(*args, **kwargs)

and_ :: [Bool] -> Bool

and returns the conjunction of a Boolean list. For the result to be True, the list must be finite; False, however, results from a False value at a finite index of a finite or infinite list.

hask.Data.List.or_(*args, **kwargs)

or_ :: [Bool] -> Bool

or returns the disjunction of a Boolean list. For the result to be False, the list must be finite; True, however, results from a True value at a finite index of a finite or infinite list.

hask.Data.List.any(*args, **kwargs)

any :: (a -> Bool) -> [a] -> Bool

Applied to a predicate and a list, any determines if any element of the list satisfies the predicate. For the result to be False, the list must be finite; True, however, results from a True value for the predicate applied to an element at a finite index of a finite or infinite list.

hask.Data.List.all(*args, **kwargs)

all :: (a -> Bool) -> [a] -> Bool

Applied to a predicate and a list, all determines if all elements of the list satisfy the predicate. For the result to be True, the list must be finite; False, however, results from a False value for the predicate applied to an element at a finite index of a finite or infinite list.

hask.Data.List.sum(*args, **kwargs)

sum :: Num a => [a] -> a

The sum function computes the sum of a finite list of numbers.

hask.Data.List.product(*args, **kwargs)

product :: Num a => [a] -> a

The product function computes the product of a finite list of numbers.

hask.Data.List.minimum(*args, **kwargs)

minimum :: Ord a => [a] -> a

minimum returns the minimum value from a list, which must be non-empty, finite, and of an ordered type. It is a special case of minimumBy, which allows the programmer to supply their own comparison function.

hask.Data.List.maximum(*args, **kwargs)

maximum :: Ord a => [a] -> a

maximum returns the maximum value from a list, which must be non-empty, finite, and of an ordered type. It is a special case of maximumBy, which allows the programmer to supply their own comparison function.

hask.Data.List.scanl(*args, **kwargs)

scanl :: (b -> a -> b) -> b -> [a] -> [b]

scanl is similar to foldl, but returns a list of successive reduced values from the left

hask.Data.List.scanl1(*args, **kwargs)

scanl1 :: (a -> a -> a) -> [a] -> [a]

scanl1 is a variant of scanl that has no starting value argument

hask.Data.List.scanr(*args, **kwargs)

scanr :: (a -> b -> b) -> b -> [a] -> [b]

scanr is the right-to-left dual of scanl.

hask.Data.List.scanr1(*args, **kwargs)

scanr1 :: (a -> a -> a) -> [a] -> [a]

scanr1 is a variant of scanr that has no starting value argument.

hask.Data.List.mapAccumL(*args, **kwargs)

mapAccumL :: (a -> x -> (a, y)) -> a -> [x] -> (a, [y])

The mapAccumL function behaves like a combination of map and foldl; it applies a function to each element of a list, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new list.

hask.Data.List.mapAccumR(*args, **kwargs)

mapAccumR :: (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])

The mapAccumR function behaves like a combination of map and foldr; it applies a function to each element of a list, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new list.

hask.Data.List.iterate(*args, **kwargs)

iterate :: (a -> a) -> a -> [a]

iterate(f, x) returns an infinite List of repeated applications of f to x: iterate(f, x) == [x, f(x), f(f(x)), …]

hask.Data.List.repeat(*args, **kwargs)

repeat :: a -> [a]

repeat(x) is an infinite list, with x the value of every element.

hask.Data.List.replicate(*args, **kwargs)

replicate :: Int -> a -> [a]

replicate(n, x) is a list of length n with x the value of every element.

hask.Data.List.cycle(*args, **kwargs)

cycle :: [a] -> [a]

cycle ties a finite list into a circular one, or equivalently, the infinite repetition of the original list. It is the identity on infinite lists.

hask.Data.List.unfoldr(*args, **kwargs)

unfoldr :: (b -> Maybe (a, b)) -> b -> [a]

The unfoldr function is a dual to foldr: while foldr reduces a list to a summary value, unfoldr builds a list from a seed value. The function takes the element and returns Nothing if it is done producing the list or returns Just (a,b), in which case, a is prepended to the list and b is used as the next element in a recursive call

hask.Data.List.take(*args, **kwargs)

take :: Int -> [a] -> [a]

take(n), applied to a list xs, returns the prefix of xs of length n, or xs itself if n > length xs

hask.Data.List.drop(*args, **kwargs)

drop :: Int -> [a] -> [a]

drop(n, xs) returns the suffix of xs after the first n elements, or [] if n > length xs

hask.Data.List.splitAt(*args, **kwargs)

splitAt :: Int -> [a] -> ([a], [a])

splitAt(n, xs) returns a tuple where first element is xs prefix of length n and second element is the remainder of the list

hask.Data.List.takeWhile(*args, **kwargs)

takeWhile :: (a -> Bool) -> [a] -> [a]

takeWhile, applied to a predicate p and a list xs, returns the longest prefix (possibly empty) of xs of elements that satisfy p

hask.Data.List.dropWhile(*args, **kwargs)

dropWhile :: (a -> Bool) -> [a] -> [a]

dropWhile(p, xs) returns the suffix remaining after takeWhile(p, xs)

hask.Data.List.dropWhileEnd(*args, **kwargs)

dropWhileEnd :: (a -> Bool) -> [a] -> [a]

The dropWhileEnd function drops the largest suffix of a list in which the given predicate holds for all elements.

hask.Data.List.span(*args, **kwargs)

span :: (a -> Bool) -> [a] -> ([a], [a])

span, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that satisfy p and second element is the remainder of the list

hask.Data.List.break_(*args, **kwargs)

break :: (a -> Bool) -> [a] -> ([a], [a])

break, applied to a predicate p and a list xs, returns a tuple where first element is longest prefix (possibly empty) of xs of elements that do not satisfy p and second element is the remainder of the list

hask.Data.List.stripPrefix(*args, **kwargs)

stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]

The stripPrefix function drops the given prefix from a list. It returns Nothing if the list did not start with the prefix given, or Just the list after the prefix, if it does.

hask.Data.List.group(*args, **kwargs)

group :: Eq a => [a] -> [[a]]

The group function takes a list and returns a list of lists such that the concatenation of the result is equal to the argument. Moreover, each sublist in the result contains only equal elements. It is a special case of groupBy, which allows the programmer to supply their own equality test.

hask.Data.List.inits(*args, **kwargs)

inits :: [a] -> [[a]]

The inits function returns all initial segments of the argument, shortest first.

hask.Data.List.tails(*args, **kwargs)

tails :: [a] -> [[a]]

The tails function returns all final segments of the argument, longest first.

hask.Data.List.isPrefixOf(*args, **kwargs)

isPrefixOf :: Eq a => [a] -> [a] -> Bool

The isPrefixOf function takes two lists and returns True iff the first list is a prefix of the second.

hask.Data.List.isSuffixOf(*args, **kwargs)

isSuffixOf :: Eq a => [a] -> [a] -> Bool

The isSuffixOf function takes two lists and returns True iff the first list is a suffix of the second. The second list must be finite.

hask.Data.List.isInfixOf(*args, **kwargs)

isInfixOf :: Eq a => [a] -> [a] -> Bool

The isInfixOf function takes two lists and returns True iff the first list is contained, wholly and intact, anywhere within the second.

hask.Data.List.isSubsequenceOf(*args, **kwargs)

isSubsequenceOf :: Eq a => [a] -> [a] -> Bool

The isSubsequenceOf function takes two lists and returns True if the first list is a subsequence of the second list.

isSubsequenceOf(x, y) is equivalent to elem(x, subsequences(y))

hask.Data.List.elem(*args, **kwargs)

elem :: Eq a => a -> [a] -> Bool

elem is the list membership predicate, elem(x, xs). For the result to be False, the list must be finite; True, however, results from an element equal to x found at a finite index of a finite or infinite list.

hask.Data.List.notElem(*args, **kwargs)

notElem :: Eq a => a -> [a] -> Bool

notElem is the negation of elem().

hask.Data.List.lookup(*args, **kwargs)

lookup :: Eq a => a -> [(a, b)] -> Maybe b

lookup(key, assocs) looks up a key in an association list.

hask.Data.List.find(*args, **kwargs)

find :: (a -> Bool) -> [a] -> Maybe a

The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Nothing if there is no such element.

hask.Data.List.filter(*args, **kwargs)

filter :: (a -> Bool) -> [a] -> [a]

filter, applied to a predicate and a list, returns the list of those elements that satisfy the predicate

hask.Data.List.partition(*args, **kwargs)

partition :: (a -> Bool) -> [a] -> ([a], [a])

The partition function takes a predicate a list and returns the pair of lists of elements which do and do not satisfy the predicate.

hask.Data.List.elemIndex(*args, **kwargs)

elemIndex :: Eq a => a -> [a] -> Maybe Int

The elemIndex function returns the index of the first element in the given list which is equal (by ==) to the query element, or Nothing if there is no such element.

hask.Data.List.elemIndices(*args, **kwargs)

elemIndices :: Eq a => a -> [a] -> [Int]

The elemIndices function extends elemIndex, by returning the indices of all elements equal to the query element, in ascending order.

hask.Data.List.findIndex(*args, **kwargs)

findIndex :: (a -> Bool) -> [a] -> Maybe Int

The findIndex function takes a predicate and a list and returns the index of the first element in the list satisfying the predicate, or Nothing if there is no such element.

hask.Data.List.findIndicies(*args, **kwargs)

findIndices :: (a -> Bool) -> [a] -> [Int]

The findIndices function extends findIndex, by returning the indices of all elements satisfying the predicate, in ascending order.

hask.Data.List.zip(*args, **kwargs)

zip :: [a] -> [b] -> [(a, b)]

zip takes two lists and returns a list of corresponding pairs. If one input list is short, excess elements of the longer list are discarded.

hask.Data.List.zip3(*args, **kwargs)

zip3 :: [a] -> [b] -> [c] -> [(a, b, c)]

zip3 takes three lists and returns a list of triples, analogous to zip.

hask.Data.List.zip4(*args, **kwargs)

zip4 :: [a] -> [b] -> [c] -> [d] -> [(a, b, c, d)]

The zip4 function takes four lists and returns a list of quadruples, analogous to zip.

hask.Data.List.zip5(*args, **kwargs)

zip5 :: [a] -> [b] -> [c] -> [d] -> [e] -> [(a, b, c, d, e)]

The zip5 function takes five lists and returns a list of five-tuples, analogous to zip.

hask.Data.List.zip6(*args, **kwargs)

zip6 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [(a, b, c, d, e, f)]

The zip6 function takes six lists and returns a list of six-tuples, analogous to zip.

hask.Data.List.zip7(*args, **kwargs)

zip7 :: [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [(a, b, c, d, e, f, g)]

The zip7 function takes seven lists and returns a list of seven-tuples, analogous to zip.

hask.Data.List.zipWith(*args, **kwargs)

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

zipWith generalises zip by zipping with the function given as the first argument, instead of a tupling function. For example, zipWith (+) is applied to two lists to produce the list of corresponding sums.

hask.Data.List.zipWith3(*args, **kwargs)

zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]

The zipWith3 function takes a function which combines three elements, as well as three lists and returns a list of their point-wise combination, analogous to zipWith.

hask.Data.List.zipWith4(*args, **kwargs)

zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]

The zipWith4 function takes a function which combines four elements, as well as four lists and returns a list of their point-wise combination, analogous to zipWith.

hask.Data.List.zipWith5(*args, **kwargs)

zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]

The zipWith5 function takes a function which combines five elements, as well as five lists and returns a list of their point-wise combination, analogous to zipWith.

hask.Data.List.zipWith6(*args, **kwargs)

zipWith6 :: (a -> b -> c -> d -> e -> f -> g) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g]

The zipWith6 function takes a function which combines six elements, as well as six lists and returns a list of their point-wise combination, analogous to zipWith.

hask.Data.List.zipWith7(*args, **kwargs)

zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]

The zipWith7 function takes a function which combines seven elements, as well as seven lists and returns a list of their point-wise combination, analogous to zipWith.

hask.Data.List.unzip(*args, **kwargs)

unzip :: [(a, b)] -> ([a], [b])

unzip transforms a list of pairs into a list of first components and a list of second components.

hask.Data.List.unzip3(*args, **kwargs)

unzip3 :: [(a, b, c)] -> ([a], [b], [c])

The unzip3 function takes a list of triples and returns three lists, analogous to unzip.

hask.Data.List.unzip4(*args, **kwargs)

unzip4 :: [(a, b, c, d)] -> ([a], [b], [c], [d])

The unzip4 function takes a list of quadruples and returns four lists, analogous to unzip.

hask.Data.List.unzip5(*args, **kwargs)

unzip5 :: [(a, b, c, d, e)] -> ([a], [b], [c], [d], [e])

The unzip5 function takes a list of five-tuples and returns five lists, analogous to unzip.

hask.Data.List.unzip6(*args, **kwargs)

unzip6 :: [(a, b, c, d, e, f)] -> ([a], [b], [c], [d], [e], [f])

The unzip6 function takes a list of six-tuples and returns six lists, analogous to unzip.

hask.Data.List.unzip7(*args, **kwargs)

unzip7 :: [(a, b, c, d, e, f, g)] -> ([a], [b], [c], [d], [e], [f], [g])

The unzip7 function takes a list of seven-tuples and returns seven lists, analogous to unzip.

hask.Data.List.nub(*args, **kwargs)

nub :: Eq a => [a] -> [a]

The nub function removes duplicate elements from a list. In particular, it keeps only the first occurrence of each element. (The name nub means essence.) It is a special case of nubBy, which allows the programmer to supply their own equality test.

hask.Data.List.delete(*args, **kwargs)

delete :: Eq a => a -> [a] -> [a]

delete(x) removes the first occurrence of x from its list argument.

It is a special case of deleteBy, which allows the programmer to supply their own equality test.

hask.Data.List.diff(*args, **kwargs)

diff :: :: Eq a => [a] -> [a] -> [a]

List difference.

hask.Data.List.union(*args, **kwargs)

union :: Eq a => [a] -> [a] -> [a]

The union function returns the list union of the two lists.

Duplicates, and elements of the first list, are removed from the the second list, but if the first list contains duplicates, so will the result. It is a special case of unionBy, which allows the programmer to supply their own equality test.

hask.Data.List.intersect(*args, **kwargs)

intersect :: Eq a => [a] -> [a] -> [a]

The intersect function takes the list intersection of two lists. It is a special case of intersectBy, which allows the programmer to supply their own equality test. If the element is found in both the first and the second list, the element from the first list will be used.

hask.Data.List.sort(*args, **kwargs)

sort :: Ord a => [a] -> [a]

The sort function implements a stable sorting algorithm. It is a special case of sortBy, which allows the programmer to supply their own comparison function.

Note: Current implementation is not lazy

hask.Data.List.sortOn(*args, **kwargs)

sortOn :: Ord b => (a -> b) -> [a] -> [a]

Sort a list by comparing the results of a key function applied to each element.

Note: Current implementation is not lazy

hask.Data.List.insert(*args, **kwargs)

insert :: Ord a => a -> [a] -> [a]

The insert function takes an element and a list and inserts the element into the list at the first position where it is less than or equal to the next element. In particular, if the list is sorted before the call, the result will also be sorted.

hask.Data.List.nubBy(*args, **kwargs)

nubBy :: (a -> a -> Bool) -> [a] -> [a]

The nubBy function behaves just like nub, except it uses a user-supplied equality predicate instead of the overloaded == function.

hask.Data.List.deleteBy(*args, **kwargs)

deleteBy :: (a -> a -> Bool) -> a -> [a] -> [a]

The deleteBy function behaves like delete, but takes a user-supplied equality predicate.

hask.Data.List.deleteFirstBy(*args, **kwargs)

deleteFirstsBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

The deleteFirstsBy function takes a predicate and two lists and returns the first list with the first occurrence of each element of the second list removed.

hask.Data.List.unionBy(*args, **kwargs)

unionBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

The unionBy function is the non-overloaded version of union.

hask.Data.List.intersectBy(*args, **kwargs)

intersectBy :: (a -> a -> Bool) -> [a] -> [a] -> [a]

The intersectBy function is the non-overloaded version of intersect.

hask.Data.List.groupBy(*args, **kwargs)

groupBy :: (a -> a -> Bool) -> [a] -> [[a]]

The groupBy function is the non-overloaded version of group.

hask.Data.List.sortBy(*args, **kwargs)

sortBy :: (a -> a -> Ordering) -> [a] -> [a]

The sortBy function is the non-overloaded version of sort.

hask.Data.List.insertBy(*args, **kwargs)

insertBy :: (a -> a -> Ordering) -> a -> [a] -> [a]

The non-overloaded version of insert.

hask.Data.List.maximumBy(*args, **kwargs)

maximumBy :: (a -> a -> Ordering) -> [a] -> a

The maximumBy function takes a comparison function and a list and returns the greatest element of the list by the comparison function. The list must be finite and non-empty.

hask.Data.List.minimumBy(*args, **kwargs)

minimumBy :: (a -> a -> Ordering) -> [a] -> a

The minimumBy function takes a comparison function and a list and returns the least element of the list by the comparison function. The list must be finite and non-empty.

hask.Data.List.genericLength(*args, **kwargs)

genericLength :: Num i => [a] -> i

The genericLength function is an overloaded version of length. In particular, instead of returning an Int, it returns any type which is an instance of Num. It is, however, less efficient than length.

hask.Data.List.genericTake(*args, **kwargs)

genericTake :: Integral i => i -> [a] -> [a]

The genericTake function is an overloaded version of take, which accepts any Integral value as the number of elements to take.

hask.Data.List.genericDrop(*args, **kwargs)

genericDrop :: Integral i => i -> [a] -> [a]

The genericDrop function is an overloaded version of drop, which accepts any Integral value as the number of elements to drop.

hask.Data.List.genericSplitAt(*args, **kwargs)

genericSplitAt :: Integral i => i -> [a] -> ([a], [a])

The genericSplitAt function is an overloaded version of splitAt, which accepts any Integral value as the position at which to split.

hask.Data.List.genericIndex(*args, **kwargs)

genericIndex :: Integral i => [a] -> i -> a

The genericIndex function is an overloaded version of !!, which accepts any Integral value as the index.

hask.Data.List.genericReplicate(*args, **kwargs)

genericReplicate :: Integral i => i -> a -> [a]

The genericReplicate function is an overloaded version of replicate, which accepts any Integral value as the number of repetitions to make.