2
(define (read-all-input)
  (local ((define line (bytes->list (read-bytes 4))))
    (if (eof-object? line)
        empty
        (cons line (read-all-input)))))

(void (read-all-input))

上面的代码失败是因为 bytes->list 需要一个字节字符串类型的参数,但是给出了 #

4

2 回答 2

3
#lang scheme

(define (read-all-input)
 (let ((b (read-bytes 4)))
  (cond
   ((eof-object? b) empty)
   (else (cons b (read-all-input)))
)))

(void (read-all-input))

此函数将字节读入字节列表。

于 2009-10-20T18:10:17.270 回答
0

我不太确定你想获得什么,但这是我的尝试:

(define read-all-input
  (lambda ()
      (let ((line (read-bytes 4)))
        (if (eof-object? line)
            '()
            (cons (bytes->list line) (read-all-input))))))
于 2009-10-20T02:48:28.387 回答