io
Standard input and standard output.
print writes to the same standard output as write and
write_line, so all three interleave in the order they ran. Every
read first writes out whatever has been written so far, so a prompt
is on screen before the program waits for an answer.
import iois_eof
def is_eof() -> Bool
Tells whether standard input has been read to the end. read_line
answers "" both for an empty line and at the end of the input, and
this is how a program tells the two apart.
Returns
true when nothing is left to read, false otherwise.
Example
read
def read() -> String
Reads everything left on standard input, from where the last read stopped to the end, line endings included.
Returns
The rest of the input, or "" when nothing is left.
Example
read_line
def read_line(prompt: String = "") -> String
Writes prompt, with no newline, then reads one line of standard input.
The line ending is not part of the answer.
Parameters
prompt: what to show before waiting for the line; nothing by default.
Returns
The line, or "" at the end of the input. Use is_eof to tell an
empty line from the end.
Example
write
def write(text: String) -> ()
Writes text to standard output exactly as it is, with no newline
after it. Use it to build a line from several pieces, and write_line
or print to end it.
Parameters
text: the characters to write.
Example
write_line
def write_line(text: String) -> ()
Writes text to standard output, then a newline. Unlike print, it
takes exactly one string and writes it as it is.
Parameters
text: the line to write, without its newline.
Example