librarylib/Play.xtl
Play: reading what a player types at the terminal, shared by the games' play.xtl programs. Every function prints its prompt, reads a line ([]R_EAD) and returns what it found; it never asks again itself (a game decides what is acceptable and asks again).
ˡl̲ine : Any a => a -> Char
The line typed, as it was typed.
ˡl̲ine ← { prompt → shown ← p̲rint! prompt ⎕R̲EAD @ }
ˡn̲umbersIn : Char -> Int
The whole numbers in a line (other characters dropped first), a vector that may be empty.
ᵖ⁼u̲se< "Play"
ᵖn̲umbersIn "move 3 to 12, then -1" 3 12 -1
ˡn̲umbersIn ← { line → f̲loor n̲umbers (line m̲ember? "0123456789 -") r̲eplicate line }
ˡn̲umbers : Any a => a -> Int
The numbers typed, a vector that may be empty.
ˡn̲umbers ← { prompt → ˡn̲umbersIn ˡl̲ine prompt }