我试图得到两个列表相交的“对立面”: 像:
let all = [1..5]
let mask = [2,3]
let res = ???
-- let res = all `intersect` mask <-- reverse/opposite ?
-- I want to get [1,4,5] ?
答案 0 :(得分:16)
您正在寻找设置差异,这是来自Data.List的\\
运算符:
Prelude> import Data.List ((\\))
Prelude Data.List> let all = [1..5]
Prelude Data.List> let mask = [2,3]
Prelude Data.List> all \\ mask
[1,4,5]