count :: Eq a => a -> [a] -> Int
count _[] = 0
count z (x:xs) | z == x = 1 + (count z xs)
| otherwise = count z xs
rmdups :: Eq a => [a] -> [a]
rmdups [] = []
rmdups (x:xs) | count x xs > 0 = rmdups xs
| otherwise = x: rmdups xs
上面的代码可以编译,但是当我输入'ababca'
rmdups 的输出时'bca'
,我希望它是'abc'
. 为什么a去那里?我一直在更改代码,但不知道为什么会这样。