https://github.com/JuliaLang/julia
Raw File
Tip revision: 9058264a69f9efc1af805c4473c946f87859b731 authored by Kristoffer Carlsson on 19 December 2021, 12:30:42 UTC
release-1.6: Set VERSION to 1.6.5 (#43397)
Tip revision: 9058264
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