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)) })
More Related Contents:
- Use of def, val, and var in scala
- What is the difference between JavaConverters and JavaConversions in Scala?
- Flattening Rows in Spark
- Why does pattern matching in Scala not work with variables?
- What are type classes in Scala useful for?
- How to pattern match on generic type in Scala?
- How to get around the Scala case class limit of 22 fields?
- Linearization order in Scala
- Using Either to process failures in Scala code
- Is there a way to control which implicit conversion will be the default used?
- Why can’t I return a concrete subtype of A if a generic subtype of A is declared as return parameter?
- how to filter out a null value from spark dataframe
- Is there a reason not to use SparkContext.getOrCreate when writing a spark job?
- What are the various join types in Spark?
- What is the rule for parenthesis in Scala method invocation?
- How to calculate the size of dataframe in bytes in Spark?
- Why does partition parameter of SparkContext.textFile not take effect?
- Cross product in Scala
- Static return type of Scala macros
- Spark Scala list folders in directory
- Exception in thread “main” java.lang.NoSuchMethodError: scala.Product.$init$(Lscala/Product;)
- How to remove parentheses around records when saveAsTextFile on RDD[(String, Int)]?
- Reading in multiple files compressed in tar.gz archive into Spark [duplicate]
- Why is this implicit ambiguity behaviour happening?
- How to wait for several Futures?
- How do you define a local var/val in the primary constructor in Scala?
- Scala 2.10 reflection, how do I extract the field values from a case class, i.e. field list from case class
- assembly-merge-strategy issues using sbt-assembly
- How to create a Dataset of Maps?
- Spark ML VectorAssembler returns strange output