List
The List library collects operations over integer lists ([Int]). Bring it into scope with import List.
The functions are grouped by purpose below; each table lists a function and its type.
Table of contents
Basic operations
| Function | Type |
|---|---|
head | [Int] -> Int |
last | [Int] -> Int |
tail | [Int] -> [Int] |
init | [Int] -> [Int] |
singleton | Int -> [Int] |
null | [Int] -> Bool |
length | [Int] -> Int |
reverse | [Int] -> [Int] |
Transforming lists
| Function | Type |
|---|---|
map | (Int -> Int) -> [Int] -> [Int] |
intersperse | Int -> [Int] -> [Int] |
concatMap | (Int -> [Int]) -> [Int] -> [Int] |
filter | (Int -> Bool) -> [Int] -> [Int] |
partition | (Int -> Bool) -> [Int] -> ([Int], [Int]) |
Folding and scanning
| Function | Type |
|---|---|
foldl | forall a:*T . (a -> Int -> a) -> a -> [Int] -> a |
foldr | forall a:*T . (Int -> a -> a) -> a -> [Int] -> a |
scanl | (Int -> Int -> Int) -> Int -> [Int] -> [Int] |
scanl1 | (Int -> Int -> Int) -> [Int] -> [Int] |
scanr | (Int -> Int -> Int) -> Int -> [Int] -> [Int] |
scanr1 | (Int -> Int -> Int) -> [Int] -> [Int] |
mapAccumL | forall a:*T . (a -> Int -> (a, Int)) -> a -> [Int] -> (a, [Int]) |
mapAccumR | forall a:*T . (a -> Int -> (a, Int)) -> a -> [Int] -> (a, [Int]) |
Searching and predicates
| Function | Type |
|---|---|
any | (Int -> Bool) -> [Int] -> Bool |
all | (Int -> Bool) -> [Int] -> Bool |
elem | Int -> [Int] -> Bool |
notElem | Int -> [Int] -> Bool |
Aggregating
| Function | Type |
|---|---|
sum | [Int] -> Int |
product | [Int] -> Int |
maximum | [Int] -> Int |
minimum | [Int] -> Int |
Extracting sublists
| Function | Type |
|---|---|
take | Int -> [Int] -> [Int] |
drop | Int -> [Int] -> [Int] |
splitAt | Int -> [Int] -> ([Int], [Int]) |
takeWhile | (Int -> Bool) -> [Int] -> [Int] |
dropWhile | (Int -> Bool) -> [Int] -> [Int] |
span | (Int -> Bool) -> [Int] -> ([Int], [Int]) |
break | (Int -> Bool) -> [Int] -> ([Int], [Int]) |
Indexing and comparison
| Function | Type |
|---|---|
nth | [Int] -> Int -> Int |
elemAt | [Int] -> Int -> Int |
equal | [Int] -> [Int] -> Bool |
Zipping
| Function | Type |
|---|---|
zipWith | (Int -> Int -> Int) -> [Int] -> [Int] -> [Int] |
zipWith3 | (Int -> Int -> Int -> Int) -> [Int] -> [Int] -> [Int] -> [Int] |