OxL Справочник OxL
РусскийEnglish

method iter.groupBy

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

Example:

oxl✓ проверяется в CI
fn main() io {
  for g in ["apple", "avocado", "banana"].iter().groupBy(s => s.slice(0, 1)) {
    print("{g.key}: {g.items}")
  }
}
Вывод
a: ["apple", "avocado"]
b: ["banana"]
pub(api) move fn groupBy<K, effect F>(key: fn(T) -> K F escaping) -> iter<Group<K, T>>  F

Сложность. O(n); the whole input is pulled at the first pull.

С версии. 1.0.0-beta

Параметры

ИмяТип
keyfn(T) -> K F escaping

Возвращает

iter<Group<K, T>> F

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/core/iter.oxl:462

См. также