[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: I/O, modules
From: |
Mike Gran |
Subject: |
Re: I/O, modules |
Date: |
Tue, 13 Nov 2012 06:50:24 -0800 (PST) |
> From: Mark H Weaver <address@hidden>
>
> As shown in the upcase program above, (read-delimited "" port) will
> read
> the whole file as a string. You need to (use-modules (ice-9 rdelim)) to
> import this procedure.
Nice. For reading entire files, I always ended up doing something like
the following (which does reveal how I think of everything in low-level C
constructs, I suppose.)
(use-modules (ice-9 rw))
(define (read-all port) (let loop ((block (make-string 32000))
(text ""))
(let ((count (read-string!/partial block port)))
(if count
(loop block
(string-append text (substring block 0 count)))
text))))-Mike