Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

## Synopsis

- (!!) :: [a] -> Int -> a
- chunksOf :: Partial => Int -> [a] -> [[a]]
- elemIndexJust :: (Partial, Eq a) => a -> [a] -> Int
- findIndexJust :: (a -> Bool) -> [a] -> Int
- findJust :: (a -> Bool) -> [a] -> a
- head :: [a] -> a
- init :: [a] -> [a]
- last :: [a] -> a
- lookupJust :: (Eq a, Partial) => a -> [(a, b)] -> b
- tail :: [a] -> [a]

# Documentation

(!!) :: [a] -> Int -> a infixl 9 #

List index (subscript) operator, starting from 0.
It is an instance of the more general `genericIndex`

,
which takes an index of any integral type.

chunksOf :: Partial => Int -> [a] -> [[a]] #

Split a list into chunks of a given size. The last chunk may contain fewer than n elements. The chunk size must be positive.

chunksOf 3 "my test" == ["my ","tes","t"] chunksOf 3 "mytest" == ["myt","est"] chunksOf 8 "" == [] chunksOf 0 "test" == undefined

elemIndexJust :: (Partial, Eq a) => a -> [a] -> Int #

elemIndexJust op = fromJust . elemIndex op

findIndexJust :: (a -> Bool) -> [a] -> Int #

findIndexJust op = fromJust . findIndex op

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

lookupJust :: (Eq a, Partial) => a -> [(a, b)] -> b #

lookupJust key = fromJust . lookup key