Or you could use the subsets
method. You'll have to convert your list to a set first though.
scala> List(1,2,3).toSet[Int].subsets.map(_.toList).toList
res9: List[List[Int]] = List(List(), List(1), List(2), List(3), List(1, 2), List(1, 3), List(2, 3), List(1, 2, 3))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…