Scala: List of pairs to pair of lists

functional-programming, scala, scala-collections

Solution

The opposite of zip? What might that be? `unzip` maybe?

scala> List("a" -> 1, "b" -> 2, "c" -> 3).unzip
res0: (List[java.lang.String], List[Int]) = (List(a, b, c),List(1, 2, 3))

Problem

I have a list of pairs: ``` val pairs = List("a" -> 1, "b" -> 2, "c" -> 3) ``` I'd like to convert it to a pair of lists: ``` List("a", "b", "c") -> List(1, 2, 3) ``` Basically, I want the opposite of zip() Any elegant way of doing so?

Original source