method iter.groupBy
Groups by key in order of first appearance (a barrier: the whole input is pulled at the first pull).
Example:
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>> FComplexity. O(n); the whole input is pulled at the first pull.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
key | fn(T) -> K F escaping |
Returns
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/iter.oxl:462