Revision 7b9fdf852c1c69085b9ac85faeefe67b093d66c6 authored by Valentin Churavy on 10 September 2023, 01:51:57 UTC, committed by GitHub on 10 September 2023, 01:51:57 UTC
1 parent bbbcc4f
Raw File
bin2hex.scm
(define (read-u8) (io.read *input-stream* 'uint8))
(define modulo mod)
(define display princ)
(let loop ((b (read-u8))
           (i 0))
  (if (not (eof-object? b))
      (begin
        (if (> i 0)
            (display ", "))
        (display "0x") (display (number->string b 16))
        (if (= 0 (modulo (+ 1 i) 16))
            (newline))
        (loop (read-u8) (+ 1 i)))))
(newline)
back to top