我有一个看起来像这样的元组列表:
let tups = [("AA","BB",1),
("AA","CC",2),
("AA","BB",3),
("VV","RR",4),
("XX","TT",5),
("BB","BB",6)]
我只想过滤掉第一个元素AA
和第二个元素的元组BB
。我试图使用:
filter (\(x,y,_) -> x /= "AA" && y /= "BB") tups
上面的命令删除第一个元素是“AA”或第二个元素是“BB”的任何元组。因此,输出为:
[("VV","RR",4), ("XX","TT",5)]
如何创建一个过滤函数来仅删除第一个元素是“AA”而第二个元素是“BB”的元组?正确的输出应该是:
[("AA","CC",2), ("VV","RR",4), ("XX","TT",5), ("BB","BB",6)]