6

我想从列表列表中删除所有出现的给定值。例如,输入:

'a' ["abc", "bc", "aa"] 

输出:

 ["bc", "bc", ""]

至今:

remove :: Eq a => a -> [[a ]] -> [[a ]]
remove y xs = filter(\x -> x/= y) xs

我收到一个错误,提前谢谢你。

4

1 回答 1

10

您需要映射外部列表。

remove y xs = map (filter(\x -> x/= y)) xs

你实际上并不需要一个 lambda,更好:

remove y xs = map (filter(/=y)) xs
于 2012-04-07T01:42:48.880 回答