arrow-fx-coroutines / arrow.fx.coroutines.stream / Stream / zipWithPreviousAndNext

zipWithPreviousAndNext

fun zipWithPreviousAndNext(): Stream<Triple<O?, O, O?>>

Zips each element of this stream with its previous and next element wrapped into Some. The first element is zipped with None as the previous element, the last element is zipped with None as the next element.

import arrow.fx.coroutines.stream.*

//sampleStart
suspend fun main(): Unit =
  Stream("The", "quick", "brown", "fox")
  .zipWithPreviousAndNext()
  .toList()
  .let(::println) //[(null,The, quick), (The, quick,brown), (quick,brown,fox), (brown,fox,null)]
//sampleEnd

Do you like Arrow?

Arrow Org
<