Is there any equivalent of the following function in Scala's standard library?
def traverse[A, B](collection: List[A])(f: A => Option[B]): Option[List[B]]
traverse
applies a function that can fail to an immutable list. It returns None
at the first failure. It returns Some(list)
if everything went fine.
Here I'm using lists, but it could be immutable hash maps for example.