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