I'm pretty sure this question might be duplicated, but I haven't come across the answer for this. Please pardon my ignorant knowledge of Scala. I'm pretty newbie.
My aim is to loop over two lists (with different length) and return List[List[Option[Double]]].
My code so far:
 def getDoubles(symbol: String, year: Int): Option[Double] = {
   return Some(140.0)
 }
 // this method loops over list of strings and range of time. returns list of list of Option[Double]
 def checkList(CSV: List[String], time: Range): List[List[Option[Double]]] = {
   // this variable is whats going to be returned at the end
   var listOfLists = List[List[Option[Double]]]()
     // So we are going to loop over our list and our time, and link each element in our list to all the elements in          our time range
   for {
     i < -CSV
     j < -time
       // the method getDoubles is pretty long, so i just made another version simplfying my question.
       // get doubles bascially returns Option of doubles
   }
   yield (listOfLists = getDoubles(j, i)::listOfLists)
   return listOfLists
 }
The above code, when I call it with more sophisticated data, it returns:
Vector(
  Some(313.062468), 
  Some(27.847252), 
  Some(301.873641), 
  Some(42.884065), 
  Some(332.373186), 
  Some(53.509768)
)
But I want to return something like this:
List(
  List(Some(313.062468), Some(27.847252)),
  List(Some(301.873641), Some(42.884065)),
  List(Some(332.373186), Some(53.509768))
)
How can I do this?
 
    