#lang scheme ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; A Very Simple Example of standard I/O ;;; Author: Yilan Gu ;;; CSC324 Lecture 6 ;;; Date: Oct. 15th, 2009 ;;; I/O details: ;;; http://docs.plt-scheme.org/reference/input-and-output.html ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Main loop of the example (define in-out (lambda () (menu) (let ((answer (read))) (cond ((eq? answer 1) (write "Hello World") (newline) (in-out)) ((eq? answer 2) (display "Hello World") (newline) (in-out)) ((eq? answer 3) (printf "~a as a string is ~s.~n" '(3 4) "(3 4)") (in-out)) ((eq? answer 4) (display "Thank you. Good bye !!")) (else (display "Bad choice. Try again.") (newline) (in-out)) ) ) ) ) (define menu (lambda () (newline) (newline) (display " ----- 1. show an example of write ------") (newline) (display " ----- 2. show an example of display ------") (newline) (display " ----- 3. show an example of printf ------") (newline) (display " ----- 4. Quit ---------------") (newline) (newline) (display " *** Please chose an option ***") (newline) (newline) ) )