我试图得到两个列表相交的“相反”:比如:
let all = [1..5]
let mask = [2,3]
let res = ???
-- let res = all `intersect` mask <-- reverse/opposite ?
-- I want to get [1,4,5] ?
您正在寻找set Difference ,它是\\
来自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]