!! package:relude

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
Safer version of !!, returns a Maybe. Get element from list using index value starting from `0`.
>>> [] !!? 0
Nothing
>>> ["a", "b", "c"] !!? 3
Nothing
>>> [1, 2, 3] !!? (-1)
Nothing
>>> ["a", "b", "c"] !!? 2
Just "c"
the deep analogue of $!. In the expression f $!! x, x is fully evaluated before the function f is applied to it.