Skip to content
Xen / docs

Search documentation

English · v0.1.0-demo.2

Type to search the documentation.

    한국어
    Xen / examples v0.1.0-demo.2

    Transforming items

    Transforming items

    Run from the repository or distribution root. Put xen on PATH, or substitute ./bin/xen.

    Terminal window
    xen check examples/iterators.xen
    xen run examples/iterators.xen
    4
    6
    iterators.xen
    // SPDX-License-Identifier: MIT OR Apache-2.0
    use std.iter;
    fn doubled(value: Int) -> Int {
    return value * 2;
    }
    #![explc]
    fn over_two(value: &Int) -> Bool {
    return *value > 2;
    }
    fn main() {
    let values = [1, 2, 3];
    for value in values.iter().map(doubled).filter(over_two) {
    println(value);
    }
    }

    Download file

    Terminal window
    xen build examples/iterators.xen -o app

    Run the generated executable on a compatible Linux machine.