November 7th, 2012, 06:52 PM
If you look into the Racket Documentation
, you'll find the section on Ports
, and specifically, the port->list
(define (minimum-list x)
(cond [(empty? (rest x)) (first x)]
[else (min (first x) (minimum-list (rest x)))]))
(display (minimum-list (port->list)))
Mind you, this probably still doesn't do quite what you want; you need to hit enter after each number, and at the end of the numbers, hit the EOF
button on the end of the entry box. It is designed mainly for reading files, so using it from the listener is something of a kludge.
As an alternative, you could use port->string
parse the numbers individually, but that's a good deal more work.
This is assuming you are using the Racket language, rather than, say, R6RS Scheme. Most of the different Scheme variants have similar procedures, however.
Last edited by Schol-R-LEA : November 7th, 2012 at 06:57 PM.