scala求交集、并集、差集命令

交集

scala> Set(1,2,3) & Set(2,4)
res1: scala.collection.immutable.Set[Int] = Set(2)

并集

scala> Set(1,2,3) | Set(2,4)
res2: scala.collection.immutable.Set[Int] = Set(1, 2, 3, 4)

 

差集

scala> Set(1,2,3) &~ Set(2,4)
res3: scala.collection.immutable.Set[Int] = Set(1, 3)

posted @ 2017-10-13 14:40  大数据技术宅  阅读(1230)  评论(0编辑  收藏  举报