views:

140

answers:

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))

The above code fails because bytes->list expects an argument of type byte string, but is given #

A: 

I'm not really sure what you want to obtain but this here's my try:

(define read-all-input
  (lambda ()
      (let ((line (read-bytes 4)))
        (if (eof-object? line)
            '()
            (cons (bytes->list line) (read-all-input))))))
Ionuț G. Stan
+1  A: 
#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))

This function reads bytes into a list of bytes.

yuguang