(List(JString(2437), JString(2445), JString(2428), JString(321)), CompactBuffer((4,1)))
and I would like after processing, the result will look like below:( (2437, CompactBuffer((4,1))), (2445, CompactBuffer((4,1))), (2428, CompactBuffer((4,1))), (321, CompactBuffer((4,1))) )
I have got a helpful reply but I am still got stuck when I try this
val pair = (List(JString(2437), JString(2445), JString(2428), JString(321)), CompactBuffer((4,1)))
val result = pair._1.map((_, pair._2))
First, pair._1
gets the list from the tuple. Then, map
performs the function on each element of the list. The function (_, pair._2)
puts the given element from the list in a new tuple together with the second part of the pair
tuple.
I got an error:
List(JString(2437), JString(2445), JString(2428), JString(321))
is a string rather than a list. Can anybody help me with that?