On Jun 18, 2014, at 15:55, Sam Tobin-Hochstadt <sa...@cs.indiana.edu> wrote:

>> I'll stick to for/list + in-port + read
> 
> Note that this combination is nicely packaged up as `(port->list)`,
> and there's a couple optional arguments and also `file->list` for
> other versions of this.

ooh. I didn't find that last night. That's certainly cleaner (but if you want 
to use the default read) and looks to be exactly the same in performance. I 
think I prefer for/list + in-port because in-port doesn't hand me an eof, so 
the resulting handler is smaller:

(go (lambda ()
      (port->list (lambda (ip)
                    (define s (read-string 16 ip))
                    (if (eof-object? s)
                        s
                        (string->number (string-trim s)))))))

vs

(go (lambda ()
      (for/list ([s (in-port (curry read-string 16))])
        (string->number (string-trim s)))))



____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to