(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 需要一个字节字符串类型的参数,但是给出了 #
#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))
此函数将字节读入字节列表。
我不太确定你想获得什么,但这是我的尝试:
(define read-all-input
(lambda ()
(let ((line (read-bytes 4)))
(if (eof-object? line)
'()
(cons (bytes->list line) (read-all-input))))))