Library with some useful operations on lists.
Author: Michael Hanus
Version: March 2009
| Exported names: |
Functions:
delete
| deleteBy
| elemIndex
| elemIndices
| find
| findIndex
| findIndices
| group
| groupBy
| insertBy
| intersect
| intersperse
| isPrefixOf
| isSuffixOf
| last
| nub
| nubBy
| partition
| replace
| sortBy
| transpose
| union
| \\
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
| Exported functions: |
:: 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.
:: a -> [a] -> [Int]
Returns the list of indices of occurrences of an element in a list.
:: (a -> Bool) -> [a] -> Maybe a
Returns the first element e of a list satisfying a predicate as (Just e), otherwise Nothing is returned.
:: (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.
:: (a -> Bool) -> [a] -> [Int]
Returns the list of indices of list elements satisfying a predicate.
:: [a] -> [a]
Removes all duplicates in the argument list.
:: (a -> a -> Bool) -> [a] -> [a]
Removes all duplicates in the argument list according to an equivalence relation.
:: a -> [a] -> [a]
Deletes the first occurrence of an element in a list.
:: (a -> a -> Bool) -> a -> [a] -> [a]
Deletes the first occurrence of an element in a list according to an equivalence relation.
:: [a] -> [a] -> [a]
Computes the difference of two lists.
Example call: (xs \\ ys)
xs
- a list
ys
- a list
ys has been removed from xs
:: [a] -> [a] -> [a]
Computes the union of two lists.
:: [a] -> [a] -> [a]
Computes the intersection of two lists.
:: a -> [a] -> [a]
Puts a separator element between all elements in a list.
Example: (intersperse 9 [1,2,3,4]) = [1,9,2,9,3,9,4]
:: [[a]] -> [[a]]
Transposes the rows and columns of the argument.
Example: (transpose [[1,2,3],[4,5,6]]) = [[1,4],[2,5],[3,6]]
:: (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.
Example: (partition (<4) [8,1,5,2,4,3]) = ([1,2,3],[8,5,4])
:: [a] -> [[a]]
Splits the list argument into a list of lists of equal adjacent
elements.
Example: (group [1,2,2,3,3,3,4]) = [[1],[2,2],[3,3,3],[4]]
:: (a -> a -> Bool) -> [a] -> [[a]]
Splits the list argument into a list of lists of related adjacent elements.
Example call: (groupBy eq xs)
eq
- the relation to classify adjacent elements
xs
- the list of elements
:: a -> Int -> [a] -> [a]
Replaces an element in a list.
Example call: (replace x p ys)
x
- the new element
p
- the position of the new element (head = 0)
ys
- the old list
:: [a] -> [a] -> Bool
Checks whether a list is a prefix of another.
Example call: (isPrefixOf xs ys)
xs
- a list
ys
- a list
:: [a] -> [a] -> Bool
Checks whether a list is a suffix of another.
Example call: (isSuffixOf xs ys)
xs
- a list
ys
- a list
:: (a -> a -> Bool) -> [a] -> [a]
Sorts a list w.r.t. an ordering relation by the insertion method.
:: (a -> a -> Bool) -> a -> [a] -> [a]
Inserts an object into a list according to an ordering relation.
Example call: (insertBy le x xs)
le
- an ordering relation (e.g., less-or-equal)
x
- an element
xs
- a list
:: [a] -> a
Returns the last element of a non-empty list.