List
Functions
O(n). Extract the last element of a list.
O(1). Extract the elements after the head of a list.
O(n). Return all elements except the last one.
O(1). Decompose a list into its head and tail.
O(n). Decompose a list into its init and last.
O(1). Test whether a list is empty.
O(n). Return the length of a list.
O(n). Append two lists.
O(n). Apply a function to each element.
O(n). Reverse a list.
O(n). Insert an element between each pair.
O(n). Insert a list between each pair of lists.
Transpose rows and columns.
All subsequences (power set).
All permutations.
O(n). Left-associative fold.
O(n). Strict left-associative fold.
O(n). Left fold with no initial value.
O(n). Strict left fold with no initial value.
O(n). Right-associative fold.
O(n). Right fold with no initial value.
O(n). Concatenate a list of lists.
O(n). Map a function over a list and concatenate the results.
O(n). Conjunction of a list of booleans.
O(n). Disjunction of a list of booleans.
O(n). Test whether any element satisfies the predicate.
O(n). Test whether all elements satisfy the predicate.
O(n). Sum of a list of numbers.
O(n). Product of a list of numbers.
O(n). Maximum element of a non-empty list.
O(n). Minimum element of a non-empty list.
O(n). Maximum element using a custom comparison function.
O(n). Minimum element using a custom comparison function.
O(n). Left-to-right scan, returning all intermediate values.
O(n). Right-to-left scan.
O(n). Map with an accumulating parameter, right to left.
Build an infinite list by repeated application.
An infinite list of the same value.
O(n). @replicate n x@ is a list of length @n@ with @x@ as each element.
Infinite repetition of a list.
Build a list from a seed value.
O(n). Take the first @n@ elements.
O(n). Drop the first @n@ elements.
O(n). @splitAt n xs == (take n xs, drop n xs)@.
O(n). Take elements while the predicate holds.
O(n). Drop elements while the predicate holds.
O(n). Drop trailing elements while the predicate holds.
O(n). Split at the first element that fails the predicate.
O(n). Split at the first element that satisfies the predicate.
O(n). Strip a prefix from a list. Returns Nothing if the prefix doesn't match.
O(n). Group adjacent equal elements.
O(n). Group adjacent elements by a predicate.
O(n²). All initial segments of a list, shortest first.
O(n). All final segments of a list, longest first.
O(n). Test whether the first list is a prefix of the second.
O(n). Test whether the first list is a suffix of the second.
O(n*m). Test whether the first list is contained in the second.
O(n+m). Test whether the first list is a subsequence of the second.
O(n). Test whether an element is in a list.
O(n). Test whether an element is not in a list.
O(n). Look up a key in an association list.
O(n). Find the first element satisfying a predicate.
O(n). Return elements that satisfy the predicate.
O(n). Partition a list by a predicate.
O(n). Indexing. Throws an error for out-of-bounds or negative index.
O(n). Find the index of the first occurrence of an element.
O(n). Find the indices of all occurrences of an element.
O(n). Find the index of the first element satisfying a predicate.
O(n). Find the indices of all elements satisfying a predicate.
O(min(n,m)). Zip two lists into a list of pairs.
O(min(n,m,o)). Zip three lists with a combining function.
zipWith7 :: (a -> b -> c -> d -> e -> f -> g -> h) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f] -> [g] -> [h]
#
O(n). Unzip a list of pairs into two lists.
O(n). Unzip a list of triples into three lists.
Unzip a list of 4-tuples.
Unzip a list of 5-tuples.
Unzip a list of 6-tuples.
Unzip a list of 7-tuples.
O(n). Split a string into lines, breaking on @\\n@.
O(n). Split a string into words, breaking on whitespace.
O(n). Join lines with newlines.
O(n). Join words with spaces.
O(n²). Remove duplicate elements, keeping the first occurrence.
O(n²). Remove duplicates using a custom equality predicate.
O(n). Remove the first occurrence of an element.
O(n). Remove the first occurrence using a custom equality predicate.
O(n*m). List difference: elements of the first list not in the second.
O(n*m). List union, preserving order and removing duplicates from the second list.
O(n*m). List union using a custom equality predicate.
O(n*m). List intersection.
O(n*m). List intersection using a custom equality predicate.
O(n log n). Sort a list in ascending order.
O(n log n). Sort using a custom comparison function.
O(n log n). Sort by comparing the results of a key function.
O(n). Insert an element into a sorted list, preserving the sort order.
O(n). Insert using a custom comparison function.
O(n). Length with a generic numeric result type.
O(n). Take with a generic integral index type.
O(n). Drop with a generic integral index type.
O(n). Split with a generic integral index type.
O(n). Indexing with a generic integral index type.
O(n). Replicate with a generic integral count type.