Suppose I have a few nested functors, e.g. List[Option[Int]]
and need to call the map
of the most inner one.
Now I am using nested m
From the question I understood that you are tying to prune the list iterator e.i. remove upper levels of list in that case you can use flatten
which convert list of lists into a single list.
I will be removing few layers of list using flatten
Code:-
val lists = List(
List(
List(
List("1"),List("2")
),
List(
List("3"),List("4")
) ,
List(
List("a"),List("b")
),
List(
List("c"),List("d")
)
)
)
val innerVal = lists.flatten.foreach(println)
results :-
List(List(1), List(2))
List(List(3), List(4))
List(List(a), List(b))
List(List(c), List(d))