My goal is to use a Map (immutable) instead of class to represent my data in Scala. I'm simply transforming the data from one source file into another format and using a Map seems reasonable rather modeling a class to represent my data.
Example:
I have a list of lists for my raw data.
val x = List(List("a","b","c"), List("x","y","z")) // the values, order matters
val y = List("field1","field2","field3") // the keys, order matters
I want to apply the schema to the raw data and create a List of Maps. Order wont matter with Map.
val z = List(Map("field1" -> "a", "field2" -> "b", "field3" -> "c"), List("field1" -> "x", "field2" -> "y", "field3" -> "z"))
I have tried zip but thats not what i want
val z = x zip(y) toMap
z: scala.collection.immutable.Map[List[String],String] = Map(List(a, b, c) -> field1, List(x, y, z) -> field2)
I keep getting stuck on how I would map over x with y and return a Map.
Some direction would be greatly appreciated.
EDITED: This approach was inspired by this talk by Rich Hickey.