[plt-scheme] reading a whole file

Eli Barzilay eli at barzilay.org
Tue Nov 4 14:06:18 EST 2008


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...

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!



More information about the plt-scheme mailing list