Estaba tratando de hacer una función que compare un elemento dado con una lista y si el elemento esta el la lista regrese un Booleano.
al compilarlo me lanza este error y no entiendo a que se refiere. apreciaria mucho su ayuda...
Occurs check: cannot construct the infinite type: a ~ [a]
• In the second argument of ‘(/=)’, namely ‘xs’
In the second argument of ‘(&&)’, namely ‘n /= xs’
In the expression: n /= x && n /= xs
• Relevant bindings include
n :: a (bound at Listas.hs:22:17)
xs :: [a] (bound at Listas.hs:22:13)
x :: a (bound at Listas.hs:22:11)
elemento :: [a] -> a -> Bool (bound at Listas.hs:21:1)
|
22 | elemento (x:xs) n = if n /= x && n /= xs then False else True
este es el código:
elemento :: (Eq a) => [a] -> a -> Bool
elemento [] a = error "no hay elementos en la lista"
elemento (x:xs) n = if n /= x && n /= xs then False else True