Giving an element in a list, which function can I use to find its index?
For instance, I want to find the index of 3 in the list [1, 2, 3, 4]
.
Which function exists in Haskell that I can use for this?
Giving an element in a list, which function can I use to find its index?
For instance, I want to find the index of 3 in the list [1, 2, 3, 4]
.
Which function exists in Haskell that I can use for this?
Take a look here:
i.e. use elemIndex
from Data.List
:
elemIndex :: Eq a => a -> [a] -> Maybe Int