guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking for end of file


From: Roland Orre
Subject: Re: Checking for end of file
Date: Fri, 13 Feb 2004 22:19:19 +0100

On Fri, 2004-02-13 at 20:57, Mike Flippin wrote:
> Could someone tell me how you check for an end of file?

Reading routines at scheme level generally return the eof-object when
hitting the end of file. This can be tested for by eof-object?, like:

(let ((in (open-input-file "test.txt")))
  (let loop
      ((result (read-line in)))
    (cond
     ((eof-object? result)
      (close-input-port in))
     (else
      (display result)
      (newline)
      (loop (read-line in))))))

Best regards
Roland






reply via email to

[Prev in Thread] Current Thread [Next in Thread]