[racket-dev] (no subject)

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Fri Jan 21 12:53:42 EST 2011

What is the best way to perform actions after a sequence terminates? Here is
a simple example that is like in-lines, but takes a path instead of a port.
It works, but I was wondering if there is a better way to do it.

(define (in-file-lines path)
  (let ((port (open-input-file path #:mode 'text)))
    (make-do-sequence
     (lambda ()
       (values
        (lambda (_) (read-line port 'any))
        void
        (void)
        void
        (lambda _ (if (eof-object? (peek-byte port))
                      (begin
                        (close-input-port port)
                        #f)
                      #t))
        void)))))

Thanks,
Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20110121/9736c1ee/attachment.html>

Posted on the dev mailing list.