traverseListWithIndex<A, B> static method
Map each element in the list to an IO using the function f
,
and collect the result in an IO<List<B>>
.
Same as IO.traverseList
but passing index
in the map function.
Implementation
static IO<List<B>> traverseListWithIndex<A, B>(
List<A> list,
IO<B> Function(A a, int i) f,
) =>
IO<List<B>>(() {
final resultList = <B>[];
for (var i = 0; i < list.length; i++) {
resultList.add(f(list[i], i).run());
}
return resultList;
});