I am new in Haskell programming. I am trying to understand syntax and semantics of this language. I am a bit curious about the semantics of grave accent . Why does this code work when we use grave accent?
elem' :: (Eq a) => a -> [a] -> Bool
elem' a [] = False
elem' a (x:xs)
| a == x = True
| otherwise = a `elem'` xs {-grave accent used in this line -}
The backquotes are used to treat any binary function as an infix operator.
a `elem'` xs
is identical to
elem' a xs
It is the complement to the use of (+)
to use a binary operator as a function:
(+) 3 5
is identical to
3 + 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With