[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Read n bytes
From: |
Neil Jerram |
Subject: |
Re: Read n bytes |
Date: |
21 Dec 2001 08:58:00 +0000 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "Neil" == Neil Jerram <address@hidden> writes:
Neil> (define (read-num-chars port len) (let loop ((i len)
Neil> (ret '())) (if (zero? i) (list->string (reverse! ret)) (loop
Neil> (- i 1) (cons (read-char port) ret)))))
Another possible approach:
(define (read-num-chars port len)
(list->string (map (lambda (i)
(read-char port))
(iota len))))
Here we're taking advantage of the iteration implicit in `map' and the
list construction performed by `iota'.
Neil