mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-07 05:06:37 +02:00
Adding bytevector-pad-left.
This commit is contained in:
parent
8c84a00840
commit
1090db5e2b
2 changed files with 8 additions and 1 deletions
|
@ -49,6 +49,12 @@
|
||||||
(+ (arithmetic-shift n 8)
|
(+ (arithmetic-shift n 8)
|
||||||
(bytevector-u8-ref bv i)))))))
|
(bytevector-u8-ref bv i)))))))
|
||||||
|
|
||||||
|
(define (bytevector-pad-left bv len)
|
||||||
|
(let ((diff (- len (bytevector-length bv))))
|
||||||
|
(if (positive? diff)
|
||||||
|
(bytevector-append bv (make-bytevector diff 0))
|
||||||
|
bv)))
|
||||||
|
|
||||||
;;> \section{Hex string conversion}
|
;;> \section{Hex string conversion}
|
||||||
|
|
||||||
;;> Big-endian conversion, guaranteed padded to even length.
|
;;> Big-endian conversion, guaranteed padded to even length.
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
(export
|
(export
|
||||||
bytevector-u16-ref-le bytevector-u16-ref-be
|
bytevector-u16-ref-le bytevector-u16-ref-be
|
||||||
bytevector-u32-ref-le bytevector-u32-ref-be
|
bytevector-u32-ref-le bytevector-u32-ref-be
|
||||||
|
bytevector-pad-left
|
||||||
integer->bytevector bytevector->integer
|
integer->bytevector bytevector->integer
|
||||||
integer->hex-string hex-string->integer
|
integer->hex-string hex-string->integer
|
||||||
bytevector->hex-string hex-string->bytevector)
|
bytevector->hex-string hex-string->bytevector)
|
||||||
(import (chibi) (srfi 33))
|
(import (scheme base) (srfi 33))
|
||||||
(include "bytevector.scm"))
|
(include "bytevector.scm"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue