I have aList[List[(Char,Int)]]. Suppose it is
List(List(('a',10), ('b',12))) What I want to do is concatenate a bunch of elements to it but they should also be from a list. To make myself a bit more clear:
I have the list:
List(List(('a',9),('a',8) ... ('a',1))) What I want to do with this list is take each element (immediately made me think of map) and add them to my original list but as a different list. I am not sure if this makes any sense so let me just show you exactly what I want in a visual manner:
// The original list should look something like this List(List(('a',10),('b',12)), List('a',9), List('a',8) ... List('a',1)) What I have so far does not return the correct result as it transforms the entire list into a list itself and not every element into a list. Here is what I have so far:
//This is hard coded. List(List(('a',10) , ('b',12))) ::: List((for(c <- 1 to 10) yield ('a',c)).toList) This would return the following:
List(List(('a',10),('b',12)), List( ('a',10), ('a',9 )... ('a', 1))) My mind is stuck at the way you would do it in ruby ( with an each statement).
Could you please point me to the right function that I should be able to use for such a thing? Is there an easier way to do something like such?
List(List('a', 11), ('b', 12)), List( ('a',10), ('a',9 )... ('a', 1)))?List(List(('a',10) , ('b',12))) <your-concat> List((for(c <- 1 to 10) yield ('a',c)).toList)? Because, I almost got what you want to achieve by first example and completely lost in last second example.