flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.
Fuzion
•
Idioms
•
Idiom # 148: Read list of integer numbers from stdin
Idiom # 148: Read list of integer numbers from stdin
See
programming-idioms.org
:
Code
# aborts when the first string that can't be # parsed as i32 is encountered l := streams.generate i32 (() -> (io.stdin.read_line.val "NaN") .parse_i32 .as_option)
What are effects?
Running Example
# usage: $ echo -e "1\n2\n3\n" | fz src/idiom148ex.fz ex => # aborts when the first string that can't be # parsed as i32 is encountered l := streams.generate i32 (() -> (io.stdin.read_line.val "NaN") .parse_i32 .as_option ) say l
What are effects?
next: NYI: Idiom # 149: Rescue the princess