OxL Reference

fn zip

Pairs the n-th elements of both streams; ends when either ends.

Example:

oxl✓ checked in CI
use std.stream { zip }

fn letters() -> stream<str> {
  for s in ["a", "b"] { yield s }
}
fn nums() -> stream<i32> {
  for i in 1..=5 { yield i }
}

fn main() io {
  var out: List<str> = []
  for await (l, n) in letters() |> zip(nums()) { out.push("{l}{n}") }
  print("{out}")
}
Output
["a1", "b2"]
pub(api) fn zip<A, B, E>(a: stream<A, E>, b: stream<B, E>) -> stream<(A, B), E>

Since. 1.0.0-beta

Parameters

NameType
astream<A, E>
bstream<B, E>

Returns

stream<(A, B), E>

Effects

none declared (pure unless the body says otherwise)

Defined in: std/stream/stream.oxl:325

See also