2014-12-03 52 views

回答

8

可以使用(\\)運營商Data.List,予以警告,它不僅能消除各自的第一個實例,因此

> [1..7] \\ [1..3] 
[4,5,6,7] 
> [1,1,1] \\ [1,2] 
[1,1] 

如果你想有一個真正的「差集」,使用Data.Set

> import qualified Data.Set as Set 
> Set.fromList [1..7] Set.\\ Set.fromList [1..3] 
> Set.fromList [1,1,1] 
fromList [1] 
> Set.fromList [1,1,1] Set.\\ Set.fromList [1,2] 
fromList [] 
相關問題