transpose
方法(或屬性)屬於 scala.collection.View.Concat
類(class),其相關用法說明如下。
用法:
def transpose[B](implicit asIterable: A => Iterable[B]): View[View[B]]
將此可迭代集合的可迭代集合轉置為可迭代集合的可迭代集合。
結果集合的類型將由可迭代集合的靜態類型引導。例如:
val xs = List(
Set(1, 2, 3),
Set(4, 5, 6)).transpose
// xs == List(
// List(1, 4),
// List(2, 5),
// List(3, 6))
val ys = Vector(
List(1, 2, 3),
List(4, 5, 6)).transpose
// ys == Vector(
// Vector(1, 4),
// Vector(2, 5),
// Vector(3, 6))
注意:即使應用於視圖或惰性集合,它也會始終強製元素。
類型參數:
- B
每個可迭代集合的元素類型。
值參數:
- asIterable
斷言此可迭代集合的元素類型是
Iterable
的隱式轉換.
返回:
可迭代集合的二維可迭代集合,具有 asn扔n此可迭代集合的第 th 列.
拋出:
- IllegalArgumentException
如果此可迭代集合中的所有集合的大小不同。
繼承自:
- collection.IterableOps.transpose
源碼:
- Iterable.scala
相關用法
- Scala Concat.tails用法及代碼示例
- Scala Concat.mkString用法及代碼示例
- Scala Concat.sortWith用法及代碼示例
- Scala Concat.addString用法及代碼示例
- Scala Concat.inits用法及代碼示例
- Scala Concat.groupMap用法及代碼示例
- Scala Concat.lengthIs用法及代碼示例
- Scala Concat.scanRight用法及代碼示例
- Scala Concat.groupBy用法及代碼示例
- Scala Concat.sizeIs用法及代碼示例
- Scala Concat.sliding用法及代碼示例
- Scala Concat.sortBy用法及代碼示例
- Scala Concat.combinations用法及代碼示例
- Scala Concat.groupMapReduce用法及代碼示例
- Scala Concat.collectFirst用法及代碼示例
- Scala Concat.sizeCompare用法及代碼示例
- Scala Concat.lengthCompare用法及代碼示例
- Scala Concat.unzip用法及代碼示例
- Scala Concat.lazyZip用法及代碼示例
- Scala Concat.partitionMap用法及代碼示例
- Scala Concat.permutations用法及代碼示例
- Scala Concat.unzip3用法及代碼示例
- Scala Cons.groupMapReduce用法及代碼示例
- Scala Cons.elementWise用法及代碼示例
- Scala Cons.combinations用法及代碼示例
注:本文由純淨天空篩選整理自scala-lang.org大神的英文原創作品 Concat.transpose。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。