This code should tell you whether or not an element a is in a list. What is wrong with this code?
istEnthalten:: a -> [a] -> Bool
istEnthalten elem [] = False
istEnthalten elem (x:xs) = if elem == x
then True
else istEnthalten elem xs
I know this one works:
istEnthalten :: a -> [a] -> Bool
istEnthalten elem [] = False
istEnthalten elem (x:xs)
| elem == x = True
| otherwise = contains elem xs
but what`s wrong with the first one?
Aucun commentaire:
Enregistrer un commentaire