>>> 3 `elem` [] False
>>> 3 `elem` [1,2] False
>>> 3 `elem` [1,2,3,4,5] TrueFor infinite structures, the default implementation of elem terminates if the sought-after value exists at a finite distance from the left side of the structure:
>>> 3 `elem` [1..] True
>>> 3 `elem` ([4..] ++ [3]) * Hangs forever *
elemIndexEnd c xs = case elemIndex c (reverse xs) of Nothing -> Nothing Just i -> Just (length xs - 1 - i)
elemIndexEnd c xs = case elemIndex c (reverse xs) of Nothing -> Nothing Just i -> Just (length xs - 1 - i)
>>> elemIndex 4 [0..] Just 4
>>> elemIndex 'o' "haskell" Nothing
>>> elemIndex 0 [1..] * hangs forever *
>>> elemIndices 'o' "Hello World" [4,7]
>>> elemIndices 1 [1, 2, 3, 1, 2, 3] [0,3]
elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b") elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a") elemAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
elems (fromList [(5,"a"), (3,"b")]) == ["b","a"] elems empty == []
elemAt 0 (fromList [5,3]) == 3 elemAt 1 (fromList [5,3]) == 5 elemAt 2 (fromList [5,3]) Error: index out of range