As an exercise, I'm implementing a simple grep function in Racket:
(define (grep-file pattern . files)
(for ([file-path (in-list files)])
(with-input-from-file file-path #:mode 'text
(lambda ()
(for ([line (read-line (current-input-port) 'return-linefeed)]
[i (in-naturals 1)])
(match line
[(regexp pattern)
(printf "~D : ~S~%" i line)]
[else (printf "~S~%" line)]))))))
I expect that read-line should read properly terminated lines from files.
Instead, each value of line in the inner for is a single character from the
file.
I can't seem to find any mention of a similar problem online, or reproduce it
in any other context. The same behavior follows regardless of whether the file
is DOS or Unix formatted.
I'm running Racket 6.2.1 on Windows 7. Thanks.
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.