read : IPort → S-expression
IPort
, read
those characters from the port that form an S-expression and produce it.
10
10
.
hello
'hello
.
(hello world)
(list 'hello 'world)
.
((ALICE 1) (BOB 2) (CARL 3))
(list (list 'ALICE 1) (list 'BOB 2) (list 'CARL 3))
read
adds list
and quote
(’)
where needed.
open-input-file : String → IPort \end{minipage}\hfil\begin{minipage}[b]{2.2in} \end \end{minipage}\par\bigskip\par{schemebox}}{Find a file by name (string), open it, and make it available as an (input) \scheme{Port}.} \lll{So composing the two functions is useful: \begin{schemebox} (read (open-input-file "gradebook.txt"))
"gradebook.txt"
, then this reads an entire grade book.
((ALICE 49 81 64) (BOB 16 31 27) (CARL 27 64 8))
(list (list 'ALICE 49 81 64) (list 'BOB 16 31 27) (list 'CARL 27 64 8))
(define gradebook (map (lambda (raw-gbe) (make-gbe (first raw-gbe) (rest raw-gbe))) (read (open-input-file "gradebook.txt"))))