(define choices '(("start window system" "startx") ("uitloggen" "exec logout") ("computer uitzetten" "exec poweroff"))) (define (print-menu) (print "\n--[ Menu ]--\n") (let1 num 1 (dolist (entry choices) (format #t "~d - ~a\n" num (car entry)) (inc! num)))) (define (read-choice) (format #t "\nkeuze: ") (flush) (let1 choice (read) (if (and (number? choice) (> choice 0) (<= choice (length choices))) choice (begin (format #t "\n*** Oeps: keuze '~a' bestaat niet.\n" choice) (read-choice))))) (define (menu) (print-menu) (let* ((choice (read-choice)) (command (cadr (list-ref choices (- choice 1))))) (print "command: " command) (menu))) (define (main args) (print args) (menu))