콘텐츠로 이동
Xen / docs

문서 검색

한국어 · v0.1.0-demo.2

검색어를 입력하세요.

    EN
    Xen / examples v0.1.0-demo.2

    파이프 입력 읽기

    파이프 입력 읽기

    저장소나 배포본의 루트에서 실행합니다. xen을 PATH에 추가하거나 ./bin/xen으로 바꾸세요.

    파이프 없이 실행하면 입력 끝을 기다립니다.

    터미널 창
    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));
    }
    }

    파일 다운로드

    터미널 창
    xen build examples/stdin_words.xen -o app

    생성한 실행 파일은 호환되는 Linux에서 실행하세요.