General shorthands and other small operations. Part of the Useful module.
Documentation
(?) :: Eq a => a -> [a] -> BoolSource
Works like python's "in" function. (Alias of elem). Simply checks if an item is in a list.
$ "Hello" ? ["Hello","there","people"] True $ "Bonjour" ? ["Hello","there","people"] False
(??) :: Eq a => [a] -> [a] -> BoolSource
Alias of as isInFixOf. Checks if list is a sublist of another list
$ "hello" ?? "Why hello there people" True $ [2,3] ?? [1,2,3,4] True $ "bonjour" ?? "why hello there people" False
(?!) :: Eq a => a -> [a] -> IntSource
Returns the index of the first occurance of an item if it is in a list. Otherwise gives an error. Starts counting from 0!
NOTE: This is not like elemIndex! It does not return a Maybe Int it returns an error if the item is not in a list. Either use elemIndex or test using ? first.
$ 'n' ?! "banana" 2 $ 'v' ?! "banana" *** Exception: Item not in list
(!/) :: [a] -> (Int, a) -> [a]Source
Takes a list and a pair (x,y) and inserts the item y into the list at position x
$ ["hello","there","people"] !/ (0,"bonjour") ["bonjour","there","people"]