带前缀的 Scala 组合

scala combinations with prefix

在 scala 中生成带有前缀的组合的优雅方法是什么?

"""
   ((pre_first, pre_second), 
   (pre_first, pre_second, thing1),
   (pre_first, pre_second, thing2),
   (pre_first, pre_second, thing3),
   (pre_first, pre_second, thing1, thing2),
   (pre_first, pre_second, thing1, thing3),
   (pre_first, pre_second, thing2, thing3))
""".stripMargin
val prefixes = Seq("pre_first", "pre_second")
val things = Seq("thing1", "thing2", "thing3")
    things.toSet.subsets.map(elem => prefixes ++ elem).foreach(println)
List(pre_first, pre_second)
List(pre_first, pre_second, thing1)
List(pre_first, pre_second, thing2)
List(pre_first, pre_second, thing3)
List(pre_first, pre_second, thing1, thing2)
List(pre_first, pre_second, thing1, thing3)
List(pre_first, pre_second, thing2, thing3)
List(pre_first, pre_second, thing1, thing2, thing3)
(0 to things.size).flatMap(i=>things.combinations(i)).map(prefixes ++ _)