- (IN-FILE <pathname> [<reader> [<eof?>]])syntax
Usage:
(FOR <datum> (IN-FILE <pathname> [<reader> [<eof?>]]))
Opens an input port from the file named by <pathname>, iterates as with IN-PORT from the newly opened input port, and closes the input port after iteration terminates.
<Datum> is an entry variable.
(define (read-lines-from-file pathname) (loop ((for line (in-file pathname read-line)) (with lines '() (cons line lines))) => (reverse lines))) (define (file-length pathname) (loop ((for char (in-file pathname)) (with count 0 (+ count 1))) => count))