Consider the following program:
;; DrScheme 103p1
;; Full Scheme
;; Matthias Felleisen
;; 11/16/2001
(require-library "core.ss")
#| ----------------------------------------------------------------------------
The program prompts the user for a number, displaying the list of numbers
that have already been entered. When the user enters the word sum, the
program returns the sum of the numbers.
|#
;; (listof Number) -> OBJ
;; effect: read from std in
(define (get-next-number alon)
(pretty-print alon)
(printf "Please enter a number or sum: ")
(flush-output)
(read))
;; (listof Number) -> (listof Number)
(define (collect-numbers alon)
(let ([x (get-next-number alon)])
(cond
[(number? x) (collect-numbers (cons x alon))]
[(and (symbol? x) (eq? x 'sum)) alon]
[else
(printf "~e is not a number and not sum~n" x)
(collect-numbers alon)])))
(apply + (collect-numbers '()))
Task: Your task is to implement this program as a CGI script. It
must be safe for the BACK and CLONE button of IE. The screen shots below
show how two important states in the interaction with the program:
You do not have to write the CGI script in Scheme. The server also supports SH, C, Perl, and Python. If you prefer one of these languages, first translate the above program into your favorite language and then implement it as a CGI script. Turn in both, the translated program and the CGI scripts.
Hints on Writing CGI Scripts: You will receive accounts for
ALTERF, our web server. The server is pointing to port 8000. Please take a
look at the current index page:
The homework is due on Tuesday 27 November 2001 before class.
Expected size: 200 lines