OxL Reference

method iter.flatMap

A lazy sequence of all elements of the sequences f(x) returns, in order.

Example:

oxl✓ checked in CI
fn main() io {
  print("{[1, 2, 3].iter().flatMap(x => [x, x * 10].iter()).collect()}")
}
Output
[1, 10, 2, 20, 3, 30]
pub(api) move fn flatMap<U, effect F>(f: fn(T) -> iter<U> F escaping) -> iter<U>  F

Complexity. O(1) to build; `f` is called once per source element.

Since. 1.0.0-beta

Parameters

NameType
ffn(T) -> iter<U> F escaping

Returns

iter<U> F

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/iter.oxl:167

See also