OxL Reference

method iter.groupBy

Groups by key in order of first appearance (a barrier: the whole input is pulled at the first pull).

Example:

oxl✓ checked in CI
fn main() io {
  for g in ["apple", "avocado", "banana"].iter().groupBy(s => s.slice(0, 1)) {
    print("{g.key}: {g.items}")
  }
}
Output
a: ["apple", "avocado"]
b: ["banana"]
pub(api) move fn groupBy<K, effect F>(key: fn(T) -> K F escaping) -> iter<Group<K, T>>  F

Complexity. O(n); the whole input is pulled at the first pull.

Since. 1.0.0-beta

Parameters

NameType
keyfn(T) -> K F escaping

Returns

iter<Group<K, T>> F

Effects

none declared (pure unless the body says otherwise)

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

See also