Is there a function in Haskell that takes as arguments a list and an element in that list and returns the index of that element in the list, i.e.
If I had the list ['a','f','d','g','b','h'] and the element 'b' it would return 4?
Is there a function in Haskell that takes as arguments a list and an element in that list and returns the index of that element in the list, i.e.
If I had the list ['a','f','d','g','b','h'] and the element 'b' it would return 4?
You're looking for the elemIndex function in Data.List:
> :m +Data.List
> :t elemIndex
elemIndex :: Eq a => a -> [a] -> Maybe Int
> elemIndex 'c' "abcde"
Just 2
fromJust function, too. :) More references at Data.Maybe.