iter
stdlib::rss::iter
Range, collection traversal, transformation, filtering, and reduction helpers.
Import
use stdlib::rss::iter;
Functions
| Function | Description |
|---|---|
range_step | Returns an array of numbers from start to stop using the given step. |
range | Returns an array of numbers from 0 up to stop. |
enumerate | Returns [index, value] pairs for an array. |
zip | Zips two arrays into [lhs, rhs] pairs up to the shorter length. |
take | Returns the first count values from an array. |
skip | Returns an array without the first count values. |
chunk | Splits an array into fixed-size chunks. |
sum | Returns the sum of numeric values. |
any_true | Returns whether any value in an array is truthy. |
all_true | Returns whether every value in an array is truthy. |
map | Applies a function to each value in an array. |
filter | Returns the values for which pred(value) is true. |
reduce | Reduces an array by applying func(acc, value) from left to right. |
each | Calls a function for each value in an array and returns null. |
Function details
range_step
pub fn range_step(start: int, stop: int, step: int) -> [int]
Returns an array of numbers from start to stop using the given step.
range
pub fn range(stop: int) -> [int]
Returns an array of numbers from 0 up to stop.
enumerate
pub fn enumerate<T>(values: [T]) -> [[int, T]]
Returns [index, value] pairs for an array.
zip
pub fn zip<L, R>(lhs: [L], rhs: [R]) -> [[L, R]]
Zips two arrays into [lhs, rhs] pairs up to the shorter length.
take
pub fn take<T>(values: [T], count: int) -> [T]
Returns the first count values from an array.
skip
pub fn skip<T>(values: [T], count: int) -> [T]
Returns an array without the first count values.
chunk
pub fn chunk<T>(values: [T], size: int) -> [[T]]
Splits an array into fixed-size chunks.
sum
pub fn sum(values: [number]) -> number
Returns the sum of numeric values.
any_true
pub fn any_true(values: [bool]) -> bool
Returns whether any value in an array is truthy.
all_true
pub fn all_true(values: [bool]) -> bool
Returns whether every value in an array is truthy.
map
pub fn map<T, U>(values: [T], func: fn(T) -> U) -> [U]
Applies a function to each value in an array.
filter
pub fn filter<T>(values: [T], pred: fn(T) -> bool) -> [T]
Returns the values for which pred(value) is true.
reduce
pub fn reduce<T, U>(values: [T], init: U, func: fn(U, T) -> U) -> U
Reduces an array by applying func(acc, value) from left to right.
each
pub fn each<T, U>(values: [T], func: fn(T) -> U) -> null
Calls a function for each value in an array and returns null.