I am starting in Scala and I want to get an index while I am iterating over a list using the map function.
For example, I have this line of code:
val x= list.flatMap(l => anotherFunction(l.param1.param2List.size * l.multiplier, l, l.param1.param2List(0)))
And I wanted to do something like this:
val x= list.flatMap(l => anotherFunction(l.param1.param2List.size * l.multiplier, l, l.param1.param2List(index)))
Is there any way to add a counter or something like that in order to get the index as if I was looping through the list in a for cycle? Is it possible or should I try another approach?