[ prog / sol / mona ]

prog


Running SchemeBBS using MIT Scheme 11.2

22 2022-05-31 22:54

To address anon's >>20 valid concerns:

(define (read-file filename)
  (let* ((chunksize   65536)
         (chunkbuffer (make-bytevector chunksize)))
    (call-with-binary-input-file
      filename
      (lambda (inport)
        (call-with-output-bytevector
          (lambda (outport)
            (let loop ()
              (let ((available (read-bytevector! chunkbuffer inport)))
                (when (not (eof-object? available))
                  (let ((written (write-bytevector chunkbuffer outport 0 available)))
                    (if (= written available)
                        (loop)
                        (error "out of memory in read-file" filename))))))))))))
56


VIP:

do not edit these