diff options
Diffstat (limited to 'depre/main.scm')
-rw-r--r-- | depre/main.scm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/depre/main.scm b/depre/main.scm index b59c5c9..525f685 100644 --- a/depre/main.scm +++ b/depre/main.scm @@ -1,5 +1,6 @@ ; https://xn--rpa.cc/irl/term.html -(define-module (depre main)) +(define-module (depre main) + #:use-module (ice-9 textual-ports)) ;; Code makes heavy use of functional code and parameters for state. (define max-100 (lambda (x) (if (> x 100) 100 x))) @@ -40,8 +41,9 @@ ;; Simple I/O (define (answer message) (lambda () + (newline) (display message) - (newline))) + (get-line (current-input-port)))) (define (bar percent) "A simple 12 character bar for life-like variable representation" @@ -55,6 +57,8 @@ (else #\space))) len)) +(define (read-number) + (string->number (get-line (current-input-port)))) ;; Basic state representation and creation: A state is a function that knows ;; how to jump to other states through a menu. @@ -75,12 +79,12 @@ (newline)) menu (iota (length menu) 1)) (display "You choose > ") - (let loop ((chosen (read))) + (let loop ((chosen (read-number))) (if (and (number? chosen) (<= chosen (length menu))) ((cdr (nth chosen menu))) (begin (display "Wrong answer. Try again > ") - (loop (read))))))) + (loop (read-number))))))) ;; States: |