OxL Reference

fn window

Tumbling time windows: the elements that arrive within d of the first element of a window, as one list.

Example:

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

fn nums() -> stream<i32> {
  for i in 1..=3 { yield i }
}

fn main() io, time {
  var sizes: List<usize> = []
  for await w in nums() |> window(1s) {
    sizes.push(w.len())
  }
  print("{sizes}")
}
Output
[3]
pub(api) fn window<T, E>(s: stream<T, E>, d: Duration) -> stream<List<T>, E>  time

Complexity. O(1) per element.

Since. 1.0.0-beta

Parameters

NameType
sstream<T, E>
dDuration

Returns

stream<List<T>, E>

Effects

time

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

See also