zjffdu
·
Dec 4, 2012
·
Viewed 13.4k times
·
Source
I have a nested tuple structure like (String,(String,Double)) and I want to transform it to (String,String,Double). I have various kinds of nested tuple, and I don't want to transform each manually. Is there any convenient way to do that?
How can I convert a list with (say) 3 elements into a tuple of size 3?
For example, let's say I have val x = List(1, 2, 3) and I want to convert this into (1, 2, 3). How can I do this?
I tried to use Map.map to convert a map into a List of Tuples.
However this fails. I did the following experiments:
val m = Map(("a" -> 1), ("b" -> 2))
//> m : scala.collection.immutable.Map[String,Int] = …
I want to make a scala function which returns a scala tuple.
I can do a function like this:
def foo = (1,"hello","world")
and this will work fine, but now I want to tell the compiler what I expect to …