[plt-scheme] reading a whole file
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.
--Carl