Reputation: 7067
I have two lists
val firstList = List(("A","B",12),("P","Q",13),("L","M",21))
val secondList = List(("A",11),("P",34),("L",43))
I want output as below
val outPutList = List(("P","Q",13,34),("L","M",21,43))
I want to compare third member of firstList to second element of secondList. This means -
I want to check second list value as secondList.map(_.2)
is greater than first list as firstList.map(_.3)
Upvotes: 3
Views: 661
Reputation: 20435
Using a for comprehension as follows,
for ( ((a,b,m), (c,n)) <- (firstList zip secondList) if n > m) yield (a,b,m,n)
Upvotes: 7