From 2 lists of the form List[(Int, String):
List[(Int, String)
l1 = List((1,\"a\"),(3,\"b\")) l2 = List((3,\"a\"),(4,\"c\"))
how can I combine t
val l = l1 ::: l2 val m = Map[String, Int]() (m /: l) { case (map, (i, s)) => { map.updated(s, i + (map.get(s) getOrElse 0))} }.toList // Note: Tuples are reversed.
But I suppose there is a more elegant way to do the updated part.
updated