fuzion-lang.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 io.stdin.with ()-> for l := io.buffered.read_line ? str String => str.parse_i32.as_option | io.end_of_file => nil while l.exists
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 io.stdin.with ()-> for l := io.buffered.read_line ? str String => str.parse_i32.as_option | io.end_of_file => nil while l.exists say l
What are effects?
last changed: 2024-07-01
next: NYI: Idiom # 149: Rescue the princess