[plt-scheme] reading a whole file

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Tue Nov 4 14:16:39 EST 2008

On Tue, Nov 4, 2008 at 2:06 PM, Eli Barzilay <eli at barzilay.org> wrote:
> On Nov  4, Jens Axel Soegaard wrote:
>> But what would you use instead of an accumulator?
> How about this:
>  (define (readlines filename)
>    (call-with-input-file filename
>      (lambda (p) (for/list ([x (in-lines p)]) x))))
> Which conveniently throws the accumulator to a different place...

Caveat: you can't reproduce the input 100% faithfully from this;
read-line discards line separators.


Posted on the users mailing list.