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

    Read a pipeline

    Read a pipeline

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

    Without a pipeline the program waits for end of input.

    Terminal window
    printf 'one two\nthree\n' | xen run examples/stdin_words.xen
    one
    two
    three
    stdin_words.xen
    // SPDX-License-Identifier: MIT OR Apache-2.0
    use std.io as io;
    use std.string as text;
    fn main() {
    let contents = match io.read_stdin() {
    Result.Ok(value) => value,
    Result.Err(error) => { panic(io.describe_error(error)); },
    };
    let words = text.split_ascii_whitespace(contents);
    for index in 0..words.len() {
    println(words.get(index));
    }
    }

    Download file

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

    Run the generated executable on a compatible Linux machine.