Xen / examples v0.1.0-demo.2
Transforming items
This topic is not available in the selected language or version. Showing the start of this section.
Transforming items
Run from the repository or distribution root. Put xen on PATH, or substitute ./bin/xen.
xen check examples/iterators.xenxen run examples/iterators.xenExpected output
Section titled “Expected output”46Complete source
Section titled “Complete source”// SPDX-License-Identifier: MIT OR Apache-2.0use 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); }}Build an executable
Section titled “Build an executable”xen build examples/iterators.xen -o appRun the generated executable on a compatible Linux machine.