OxL Reference

method iter.chunks

Consecutive groups of n elements (the last one may be shorter).

Example:

oxl✓ checked in CI
fn main() io {
  print("{[1, 2, 3, 4, 5].iter().chunks(2).collect()}")
}
Output
[[1, 2], [3, 4], [5]]
pub(api) move fn chunks<I>(n: I) -> iter<List<T>>

Complexity. O(n) in the number of elements; each chunk is a new list.

Since. 1.0.0-beta

Parameters

NameType
nI

Returns

iter<List<T>>

Effects

none declared (pure unless the body says otherwise)

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

See also