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.
Source: stackoverflow.com
Related Query
- Scala: Iterating over a Future of list of tuples containing lists as well. Need a final result of Future of tuple
- Iterating over a List and waiting for a Future to complete in Scala
- Scala transform list of tuples to a tuple of lists
- Using scala parallelism when iterating over a java converted List to immutable
- Iterate over an existing map against a list of tuples scala
- How to group a list of tuples sorted by first element into two lists containing overlapping and non overlapping tuples
- scala filter a list of lists of tuples
- Scala given list map / filter / take without iterating over whole list
- Scala - implicit evidence of list of tuples of lists
- how to iterate over list of lists in scala
- Iterating over java List that involves Java generics <?> in Scala
- Iterating over a Scala wrapped list
- Iterating over Java collections in Scala
- Unable to use for comprehension to map over List within Future
- Scala - convert List of Lists into a single List: List[List[A]] to List[A]
- Scala for loop over two lists simultaneously
- Scala - Two Lists to Tuple List
- iterating over Scala collections in Java
- What are advantages of a Twitter Future over a Scala Future?
- Add two tuples containing simple elements in Scala
- Zipper to iterate over list in Scala
- Scala List of tuples to flat list
- Scala collections: why do we need a case statement to extract values tuples in higher order functions?
- Dropping multiple columns from Spark dataframe by Iterating through the columns from a Scala List of Column names
- scala build up string from iterating over map
- Looping through a list of tuples in Scala
- fold list of tuples in scala with destructuring
- Scala, converting multiple lists to list of tuples
- map error when applying on list of tuples in scala
- Is there a scala list operation that makes tuples from lists?
More Query from same tag
- How to avoid dropping message due to lock timeout in akka actor?
- How can I map a "y"/"n" column to Boolean in Scala's Slick?
- Flashing value to a <select> element in Play Framework
- Scala type error
- Adding unmanagedJars to proguardLibraryJars in SBT
- ORM for Lift: Mapper or JPA?
- scala: are lists really immutable?
- Play2/Scala Custom JSON field validation
- How to put Array[Row] into JSON string
- How to create a UDF to find index in an array column
- Scala HTML parser object usage
- Scala Option ||
- Parsing HTML with Spray
- form (error: cannot find symbol )
- How do I make Gatling capture request while reading from the session?
- Java Dependency Management
- Pattern matching with OR logic
- How to replace all numbers and "." by "" of a column in Dataframes spark scala
- json4s JValue scala classTag works wrong
- Using filterNot with a Map
- How to list all objects in a Scala object?
- How to extract lines that come in between two headers starting with a specific character?
- scalatest "A stack" should "do something" -- wtf? How is should a method of string?
- Whats the benefit of using scalaz Tag instead of a case class
- nth entry matching the first quoted item in tuple
- Iterating an immutable Array and updating every element in the array, based on other elements
- Select Dataframe columns by unpacking a collection of columns in conjunction with another collection
- Error : java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
- How to type unicode 'rightwards double arrow' on a keyboard
- Filtering a list of (A, Option[B]) and extracting value from Option