traverseIterable<R, E, A, B> static method
Traverse an Iterable with the given function, collecting the results.
Implementation
static ZIO<R, E, IList<B>> traverseIterable<R, E, A, B>(
Iterable<A> iterable,
ZIO<R, E, B> Function(A _) f,
) =>
ZIO.from((ctx) {
if (iterable.isEmpty) {
return Exit.right(IList());
}
return iterable
.map((a) => f(a))
.fold<ZIO<R, E, IList<B>>>(
ZIO.succeed(IList()),
(acc, zio) => acc.zipWith(zio, (a, B b) => a.add(b)),
)
.unsafeRun(ctx);
});