Gallaoui
Gallaoui

Reputation: 511

Meaning of "!!" in Haskell

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

Answers (1)

sepp2k
sepp2k

Reputation: 370172

!! is a function that returns the ith 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

Related Questions