fn window
Tumbling time windows: the elements that arrive within d of the first element of a window, as one list.
Example:
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}")
}Вывод
[3]
pub(api) fn window<T, E>(s: stream<T, E>, d: Duration) -> stream<List<T>, E> timeСложность. O(1) per element.
С версии. 1.0.0-beta
Параметры
Возвращает
Эффекты
time
Определено в: std/stream/stream.oxl:421