traverseList<A, B> static method

Option<List<B>> traverseList<A, B>(
  1. List<A> list,
  2. Option<B> f(
    1. A a
    )
)

Map each element in the list to an Option using the function f, and collect the result in an Option<List<B>>.

If any mapped element of the list is None, then the final result will be None.

Same as Option.traverseListWithIndex but without index in the map function.

Implementation

static Option<List<B>> traverseList<A, B>(
  List<A> list,
  Option<B> Function(A a) f,
) =>
    traverseListWithIndex<A, B>(list, (a, _) => f(a));