[B], with f: @escaping (A, B) -> C ) -> [C] { a.flatMap { x in b.map { y in f(x, y) } } } func zip<A, B, C>( _ a: Result<A, Error>, _ b: Result<B, Error>, with f: @escaping (A, B) -> C ) -> Result<C, Error> { a.flatMap { x in b.map { y in f(x, y) } } }