Combining two lists into one in Scala

Ok. So first you will need to convert first list to map.

val l1 = List((1,1),(4,4),(5,4),(8,4),(9,5))
val l2 = List((1,4),(1,9),(5,9),(8,9))

val mapL1 = l1.toMap

val requiredList = l2.map({ case (i, j) => (mapL1(i), mapL1(j)) })

Browse More Popular Posts

Leave a Comment