Library with some useful operations on lists.
Author: Michael Hanus, Bjoern Peemoeller
Version: November 2020
elemIndex
:: Eq a => a > [a] > Maybe Int
Returns the index i
of the first occurrence of an element in a list
as (Just i) , otherwise Nothing
is returned.

elemIndices
:: Eq a => a > [a] > [Int]
Returns the list of indices of occurrences of an element in a list. 
find
:: (a > Bool) > [a] > Maybe a
Returns the first element e
of a list satisfying a predicate
as (Just e) ,
otherwise Nothing
is returned.

findIndex
:: (a > Bool) > [a] > Maybe Int
Returns the index i
of the first occurrences of a list element
satisfying a predicate as (Just i) , otherwise Nothing
is returned.

findIndices
:: (a > Bool) > [a] > [Int]
Returns the list of indices of list elements satisfying a predicate. 
nub
:: Eq a => [a] > [a]
Removes all duplicates in the argument list. 
nubBy
:: (a > a > Bool) > [a] > [a]
Removes all duplicates in the argument list according to an equivalence relation. 
delete
:: Eq a => a > [a] > [a]
Deletes the first occurrence of an element in a list. 
deleteBy
:: (a > a > Bool) > a > [a] > [a]
Deletes the first occurrence of an element in a list according to an equivalence relation. 
(\\)
:: Eq a => [a] > [a] > [a]
Computes the difference of two lists. 
union
:: Eq a => [a] > [a] > [a]
Computes the union of two lists. 
unionBy
:: (a > a > Bool) > [a] > [a] > [a]
Computes the union of two lists according to the given equivalence relation 
intersect
:: Eq a => [a] > [a] > [a]
Computes the intersection of two lists. 
intersectBy
:: (a > a > Bool) > [a] > [a] > [a]
Computes the intersection of two lists according to the given equivalence relation 
intersperse
:: a > [a] > [a]
Puts a separator element between all elements in a list. 
intercalate
:: [a] > [[a]] > [a]
intercalate xs xss
is equivalent to (concat (intersperse xs xss)) .

transpose
:: [[a]] > [[a]]
Transposes the rows and columns of the argument. 
diagonal
:: [[a]] > [a]
Diagonalization of a list of lists. 
permutations
:: [a] > [[a]]
Returns the list of all permutations of the argument. 
partition
:: (a > Bool) > [a] > ([a],[a])
Partitions a list into a pair of lists where the first list contains those elements that satisfy the predicate argument and the second list contains the remaining arguments. 
group
:: Eq a => [a] > [[a]]
Splits the list argument into a list of lists of equal adjacent elements. 
groupBy
:: (a > a > Bool) > [a] > [[a]]
Splits the list argument into a list of lists of related adjacent elements. 
splitOn
:: Eq a => [a] > [a] > [[a]]
Breaks the second list argument into pieces separated by the first list argument, consuming the delimiter. 
split
:: (a > Bool) > [a] > [[a]]
Splits a list into components delimited by separators, where the predicate returns True for a separator element. 
inits
:: [a] > [[a]]
Returns all initial segments of a list, starting with the shortest. 
tails
:: [a] > [[a]]
Returns all final segments of a list, starting with the longest. 
replace
:: a > Int > [a] > [a]
Replaces an element in a list. 
isPrefixOf
:: Eq a => [a] > [a] > Bool
Checks whether a list is a prefix of another. 
isSuffixOf
:: Eq a => [a] > [a] > Bool
Checks whether a list is a suffix of another. 
isInfixOf
:: Eq a => [a] > [a] > Bool
Checks whether a list is contained in another. 
sort
:: Ord a => [a] > [a]
The default sorting operation, mergeSort, with standard ordering <= .

sortBy
:: (a > a > Bool) > [a] > [a]
Sorts a list w.r.t. 
insertBy
:: (a > a > Bool) > a > [a] > [a]
Inserts an object into a list according to an ordering relation. 
last
:: [a] > a
Returns the last element of a nonempty list. 
init
:: [a] > [a]
Returns the input list with the last element removed. 
sum
:: Num a => [a] > a
Returns the sum of a list of integers. 
product
:: Num a => [a] > a
Returns the product of a list of integers. 
maximum
:: Ord a => [a] > a
Returns the maximum of a nonempty list. 
maximumBy
:: (a > a > Ordering) > [a] > a
Returns the maximum of a nonempty list according to the given comparison function 
minimum
:: Ord a => [a] > a
Returns the minimum of a nonempty list. 
minimumBy
:: (a > a > Ordering) > [a] > a
Returns the minimum of a nonempty list according to the given comparison function 
scanl
:: (a > b > a) > a > [b] > [a]
scanl
is similar to foldl , but returns a list of successive
reduced values from the left:
scanl f z [x1, x2, ...] == [z, z f
x1, (z f
x1) f
x2, ...]

scanl1
:: (a > a > a) > [a] > [a]
scanl1
is a variant of scanl
that has no starting value argument:
scanl1 f [x1, x2, ...] == [x1, x1 f
x2, ...]

scanr
:: (a > b > b) > b > [a] > [b]
scanr
is the righttoleft dual of scanl .

scanr1
:: (a > a > a) > [a] > [a]
scanr1
is a variant of scanr
that has no starting value argument.

mapAccumL
:: (a > b > (a,c)) > a > [b] > (a,[c])
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.

mapAccumR
:: (a > b > (a,c)) > a > [b] > (a,[c])
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.

cycle
:: [a] > [a]
Builds an infinite list from a finite one. 
unfoldr
:: (a > Maybe (b,a)) > a > [b]
Builds a list from a seed value. 
Returns the index 
Returns the list of indices of occurrences of an element in a list. 
Returns the first element 
Returns the index 
Returns the list of indices of list elements satisfying a predicate. 
Removes all duplicates in the argument list. 
Removes all duplicates in the argument list according to an equivalence relation. 
Deletes the first occurrence of an element in a list. 
Deletes the first occurrence of an element in a list according to an equivalence relation. 
Computes the difference of two lists.

Computes the union of two lists. 
Computes the union of two lists according to the given equivalence relation 
Computes the intersection of two lists. 
Computes the intersection of two lists according to the given equivalence relation 
Puts a separator element between all elements in a list.
Example:


Transposes the rows and columns of the argument.
Example: 
Diagonalization of a list of lists. Fairly merges (possibly infinite) list of (possibly infinite) lists.

Returns the list of all permutations of the argument. 
Partitions a list into a pair of lists where the first list contains those elements that satisfy the predicate argument and the second list contains the remaining arguments.
Example: 
Splits the list argument into a list of lists of equal adjacent elements.
Example: 
Splits the list argument into a list of lists of related adjacent elements.

Breaks the second list argument into pieces separated by the first list argument, consuming the delimiter. An empty delimiter is invalid, and will cause an error to be raised. 
Splits a list into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. split (==[a](#a)) "aabbaca" == ["","","bb","c",""] split (==[a](#a)) "" == [""] 
Returns all initial segments of a list, starting with the shortest.
Example:

Returns all final segments of a list, starting with the longest.
Example:

Replaces an element in a list.

Checks whether a list is a prefix of another.

Checks whether a list is a suffix of another.

Checks whether a list is contained in another.

The default sorting operation, mergeSort, with standard ordering 
Sorts a list w.r.t. an ordering relation by the insertion method. 
Inserts an object into a list according to an ordering relation.

Returns the last element of a nonempty list.

Returns the input list with the last element removed.

Returns the sum of a list of integers. 
Returns the product of a list of integers. 
Returns the maximum of a nonempty list.

Returns the maximum of a nonempty list according to the given comparison function

Returns the minimum of a nonempty list.

Returns the minimum of a nonempty list according to the given comparison function





The 
The 
Builds an infinite list from a finite one.

Builds a list from a seed value. 