【发布时间】:2021-12-09 00:56:21
【问题描述】:
实现
filterA2 :: [Char] -> [Char] -> ([Char], [Char])函数,从两个列表中删除字符'a'和'A'并将结果作为一对返回。例如:
filterA2 "Always" "runAway" == ("lwys", "runwy")
filterA2 "Cherry" "Tree" == ("Cherry", "Tree")
到目前为止,我已经尝试过:
filterA2 [] [] = ([], [])
filterA2 ['a'] ['a'] = ([], [])
filterA2 ['A'] ['A'] = ([], [])
filterA2 ['a'] [xs] = ([], [xs])
filterA2 [xs] ['a'] = ([xs], [])
filterA2 ['A'] [xs] = ([], [xs])
filterA2 [xs] ['A'] = ([xs], [])
filterA2 (x:xs) (y:ys) = filterA2 (xs) (ys)
无论我输入什么,它总是返回("", "")。我可能使用了太多基本案例。
【问题讨论】: