我的列表是 [[String]],它看起来像 [["A1","A2","A3"],["A1","A2","B1"],["A1","A2" “B2”].....]
我的代码如下所示
List = [[x,y,z] | x <- l1, y<- l2, z <- l3]
where l1 = ["A1","A2","A3","B1","B2","B3","C1","C2","C3","D1","D2","D3"];
l2 = ....;
l3 = ....
compareTo :: [String] -> [String] -> Bool
compareTo x y
|length (intersect x y) == length x =True
|otherwise =False
removeDuplication :: [[String]] -> [[String]]
removeDuplication (x:xs) = nubBy compareTo (x:xs)
在这种情况下,没有考虑元素的顺序,这意味着[“A1”,“A2”,“A3”]和[“A2”,“A3”,“A1”]是重复的。
我想使用“nubBy”和“compareTo”函数来构建我的 removeDuplication 函数,但我不确定如何将一个元素与列表中的所有其他元素进行比较。