Scala transform list of tuples to a tuple of lists

You want unzip

scala> List((1,"a"), (3, "b"), (4, "d")).unzip
res1: (List[Int], List[String]) = (List(1, 3, 4),List(a, b, d))

Similarly there is an unzip3 for List[Tuple3[A, B, C]], though anything of higher arity you’d have to implement yourself.

scala> List((1,"a", true), (3, "b", false), (4, "d", true)).unzip3
res2: (List[Int], List[String], List[Boolean]) = (List(1, 3, 4),List(a, b, d),List(true, false, true))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)