clean up read_line

This commit is contained in:
Kartik K. Agaram 2021-05-07 11:37:48 -07:00
parent 91f76e6b22
commit d8298d1a2a
1 changed files with 6 additions and 9 deletions

View File

@ -45,16 +45,13 @@
(if (<= e2 dx)
dx
0))))))))))))))])
(read_line_2 . [(def read_line_2 (fn (keyboard stream)
((fn (c)
(if (= c 10)
stream
(if (= c 0)
stream
(read_line_2 keyboard (write stream c)))))
(key keyboard))))])
(read_line . [(def read_line (fn (keyboard)
(read_line_2 keyboard (stream))))])
(let str (stream)
(let c (key keyboard)
(while (not (or (= c 0) (= c 10)))
(write str c)
(set c (key keyboard))))
str)))])
(chessboard . [(def chessboard (fn (screen px)
(chessboard1 screen px 0 15)))])
(chessboard1 . [(def chessboard1 (fn (screen px y color)