transpose

trait Collection[A] {
  def transpose[B]: Collection[Collection[B]]
}

transpose takes this collection of m x n elements and creates a new collection of n x m elements.

If not all the subcollections have the same size then this function throws an IllegalArgumentException exception.