Reputation: 511
elementAt :: [a] -> Int -> a
elementAt list i = list !! (i-1)
This Function return the i'th element of a list. For Example elementAt "haskell" 5 return 'e' can anyone explain me whats the meaning of "!!" , i cant find it anywhere .
Upvotes: 2
Views: 259
Reputation: 370172
!!
is a function that returns the i
th elements of a list (0-indexed).
Its documentation can be found here:
List index (subscript) operator, starting from 0. It is an instance of the more general
genericIndex
, which takes an index of any integral type.
Upvotes: 4