我有两个清单:
val list1 = List("word1","word2","word2","word3","word1")
val list2 = List("word1","word4")
我想从中删除所有出现的list2
元素list1
,即我想要
List("word2","word2","word3") <= list1 *minus* list2
我这样做了list1 diff list2
,这让我List("word2","word2","word3","word1")
只删除了第一次出现的“word1”。
我无法将其转换为集合,因为我需要有关重复项的知识(请参阅上面的“word2”)。该怎么办?