iter
Generated by tinox doc
tinox.core.iter, bundled with the compiler and also available as a standalone tinox-central package.
Map filter reduce
import tinox.core.iter
class Main
{
fnc main() -> Int32
{
const numbers: List<Int64> = [1, 2, 3, 4, 5]
const doubled: List<Int64> = Iter::map<Int64, Int64>(numbers, n => n * 2)
const evens: List<Int64> = Iter::filter(doubled, n => n % 4 == 0)
const sum: Int64 = Iter::reduce<Int64, Int64>(evens, 0, (acc, n) => acc + n)
println("sum: " + sum.toString())
const it: Iterator = Iter::range(0, 3)
while it.hasNext()
{
println(it.next().toString())
}
return 0
}
}
class Iter
Methods
fn range(start: Int64, end: Int64) → Iterator
fn rangeStep(start: Int64, end: Int64, step: Int64) → Iterator
fn repeat(value: T, count: Int64) → List<T>
fn cycle(list: List<T>) → Iterator
fn enumerate(list: List<T>) → List<Pair<Int64, T>>
fn zip(a: List<T>, b: List<U>) → List<Pair<T, U>>
fn map(list: List<T>, transform: fnc(T) -> U) → List<U>
fn filter(list: List<T>, predicate: fnc(T) -> Bool) → List<T>
fn reduce(list: List<T>, initial: U, combiner: fnc(U, T) -> U) → U
class Iterator
Fields
current | Int64 | |
end | Int64 | |
step | Int64 | |
data | List<Int64> | |
cycled | Bool |
Methods
fn hasNext() → Bool
fn next() → Int64