score:1

Accepted answer

something like

a.map(_.unzip match { case (x, y) => (x.flatten, y.flatten) })

score:0

please excuse the unruly number of brackets in the below example but this seems to work:

case class thing()

val a: future[list[(list[thing], list[thing])]] = {
  future.successful(list((list(thing()), list(thing()))))
}

val b: future[(list[thing], list[thing])] = {
  a.map(x => (x.unzip._1.flatten, x.unzip._2.flatten))
}

await.ready(b, duration.inf)
// scala.concurrent.future[(list[thing], list[thing])] =
// future(success((list(thing()),list(thing()))))

more on unzip here.


Related Query

More Query from same tag