lazyZip
方法(或屬性)屬於 scala.collection.View.ZipWithIndex
類(class),其相關用法說明如下。
用法:
def lazyZip[B](that: Iterable[B]): LazyZip2[(A, Int), B, ZipWithIndex[A]]
類似於zip
,除了每個集合中的元素在返回的LazyZip2
裝飾器上調用嚴格操作之前不會被消耗.
可以鏈接對lazyZip
的調用以支持更高的元組(最多 4 個),而不會產生構建和解構中間元組的費用。
val xs = List(1, 2, 3)
val res = (xs lazyZip xs lazyZip xs lazyZip xs).map((a, b, c, d) => a + b + c + d)
// res == List(4, 8, 12)
類型參數:
- B
每個最終對中第二個元素的類型
值參數:
- that
提供每個最終對的第二個元素的可迭代對象
返回:
一個裝飾器
LazyZip2
,它允許對延遲評估的對或對lazyZip
的鏈式調用執行嚴格的操作.還支持隱式轉換為Iterable[(A, B)]
。繼承自:
- collection.Iterable.lazyZip
源碼:
- Iterable.scala
相關用法
- Scala ZipWithIndex.inits用法及代碼示例
- Scala ZipWithIndex.partitionMap用法及代碼示例
- Scala ZipWithIndex.scanRight用法及代碼示例
- Scala ZipWithIndex.transpose用法及代碼示例
- Scala ZipWithIndex.groupMap用法及代碼示例
- Scala ZipWithIndex.tails用法及代碼示例
- Scala ZipWithIndex.sliding用法及代碼示例
- Scala ZipWithIndex.sizeIs用法及代碼示例
- Scala ZipWithIndex.sizeCompare用法及代碼示例
- Scala ZipWithIndex.unzip3用法及代碼示例
- Scala ZipWithIndex.collectFirst用法及代碼示例
- Scala ZipWithIndex.addString用法及代碼示例
- Scala ZipWithIndex.groupBy用法及代碼示例
- Scala ZipWithIndex.mkString用法及代碼示例
- Scala ZipWithIndex.unzip用法及代碼示例
- Scala ZipWithIndex.groupMapReduce用法及代碼示例
- Scala ZippedIterable2.unzip用法及代碼示例
- Scala ZippedIterable2.addString用法及代碼示例
- Scala ZipAll.groupBy用法及代碼示例
- Scala ZippedIterable3.transpose用法及代碼示例
- Scala ZipAll.unzip用法及代碼示例
- Scala ZippedIterable3.inits用法及代碼示例
- Scala Zip.transpose用法及代碼示例
- Scala ZipAll.addString用法及代碼示例
- Scala ZipAll.inits用法及代碼示例
注:本文由純淨天空篩選整理自scala-lang.org大神的英文原創作品 ZipWithIndex.lazyZip。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。