OxL Reference

fn map

Applies f to every element.

Example:

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

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

fn main() io {
  var out: List<i32> = []
  for await x in nums() |> map(x => x * 10) { out.push(x) }
  print("{out}")
}
Output
[10, 20, 30]
pub(api) fn map<T, U, E, effect F>(s: stream<T, E>, f: fn(T) -> U F escaping) -> stream<U, E>  F

Since. 1.0.0-beta

Parameters

NameType
sstream<T, E>
ffn(T) -> U F escaping

Returns

stream<U, E> F

Effects

none declared (pure unless the body says otherwise)

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

See also