test :: String -> String -> Int
test' x y n = n
test' "" (y:ys) n = error "error"
test' (x:xs) "" n = error "error"
test' (x:xs) (y:ys) n =
if x == y
then test' xs ys n
else test' xs ys (n+1)
test a b = test' a b 0
当我编译,我得到这样的输出:哈斯克尔 - 模式匹配(ES)重叠
Warning: Pattern match(es) are overlapped
得到的答复永远是“0”,这是不是我的本意。代码有什么问题以及如何解决它?
非常有帮助!我学到了很多!谢谢 – Ferry