Zip multiple sequences

后端 未结 7 1721
眼角桃花
眼角桃花 2020-12-06 09:20

I am trying to zip multiple sequences to form a long tuple:

val ints = List(1,2,3)
val chars = List(\'a\', \'b\', \'c\')
val strings = List(\"Al         


        
7条回答
  •  执笔经年
    2020-12-06 09:27

    Using product-collections

    scala> ints flatZip chars flatZip strings flatZip bools
    res0: org.catch22.collections.immutable.CollSeq4[Int,Char,String,Boolean] = 
    CollSeq((1,a,Alpha,true),
            (2,b,Beta,false),
            (3,c,Gamma,false))
    

    This currently works for arity 1 - 22. As you can see the types are preserved.

提交回复
热议问题