:: [a] -> Int -> a -package:ghc-lib-parser

List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type. WARNING: This function is partial, and should only be used if you are sure that the indexing will not fail. Otherwise, use !?. WARNING: This function takes linear time in the index.

Examples

>>> ['a', 'b', 'c'] !! 0
'a'
>>> ['a', 'b', 'c'] !! 2
'c'
>>> ['a', 'b', 'c'] !! 3
*** Exception: Prelude.!!: index too large
>>> ['a', 'b', 'c'] !! (-1)
*** Exception: Prelude.!!: negative index
Synonym for !!, but includes more information in the error message.
List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type.
>>> ['a', 'b', 'c'] !! 0
'a'

>>> ['a', 'b', 'c'] !! 2
'c'

>>> ['a', 'b', 'c'] !! 3
*** Exception: Prelude.!!: index too large

>>> ['a', 'b', 'c'] !! (-1)
*** Exception: Prelude.!!: negative index
WARNING: This function is partial. You can use atMay instead.
List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type.
List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type.
>>> ['a', 'b', 'c'] !! 0
'a'

>>> ['a', 'b', 'c'] !! 2
'c'

>>> ['a', 'b', 'c'] !! 3
*** Exception: Prelude.!!: index too large

>>> ['a', 'b', 'c'] !! (-1)
*** Exception: Prelude.!!: negative index
A variant of !! that might provide more informative error messages if the index is out of bounds. Precondition: The index should not be out of bounds.
(!!) but with a better error message if it fails. Use this only where it shouldn't fail!
like !! selects nth element from xs, but wraps over at the end of xs
>>> map ((!!!) [1,3,5]) [0,1,2,3,4,5]
[1,3,5,1,3,5]
List index (subscript) operator, starting from 0. It is an instance of the more general genericIndex, which takes an index of any integral type.
>>> ['a', 'b', 'c'] !! 0
'a'

>>> ['a', 'b', 'c'] !! 2
'c'

>>> ['a', 'b', 'c'] !! 3
*** Exception: Prelude.!!: index too large

>>> ['a', 'b', 'c'] !! (-1)
*** Exception: Prelude.!!: negative index
WARNING: This function is partial. You can use <atMay https://hackage.haskell.org/package/safe-0.3.19/docs/Safe.html#v:atMay> instead.
(‼) = (!!) U+203C, DOUBLE EXCLAMATION MARK
The genericIndex function is an overloaded version of !!, which accepts any Integral value as the index.
The index must be smaller than the length of the list, otherwise the result is undefined.
Select one of the provided alternatives given a number.
O(1) Indexing
O(1) Unsafe indexing without bounds checking
Optional more efficient implementation of indexing. Shouldn't be used directly, use ! instead.
Retrieve vector's element at index. Generic implementation is O(n) but more efficient one is used when possible.
Infix version of unsafeIndex.
Similar to !! but with flipped arguments. get element from list using index value starting from `0`.
>>> at 2 ["a", "b", "c"]
"c"
it is also useful when used in a partially applied position like:
>>> map (at 1) [["a","b","c"], ["a","b","c"], ["a","b","c"]]
["b","b","b"]