small refactor
This commit is contained in:
parent
82f82da213
commit
e795b4a75a
|
@ -605,24 +605,24 @@
|
||||||
|
|
||||||
;;; 6.9 bytevector
|
;;; 6.9 bytevector
|
||||||
|
|
||||||
(define (bytevector . objs)
|
(define (bytevector->list v start end)
|
||||||
(let ((len (length objs)))
|
(do ((i start (+ i 1))
|
||||||
|
(res '()))
|
||||||
|
((= i end)
|
||||||
|
(reverse res))
|
||||||
|
(set! res (cons (bytevector-u8-ref v i) res))))
|
||||||
|
|
||||||
|
(define (list->bytevector list)
|
||||||
|
(let ((len (length list)))
|
||||||
(let ((v (make-bytevector len)))
|
(let ((v (make-bytevector len)))
|
||||||
(do ((i 0 (+ i 1))
|
(do ((i 0 (+ i 1))
|
||||||
(l objs (cdr l)))
|
(l list (cdr l)))
|
||||||
((= i len)
|
((= i len)
|
||||||
v)
|
v)
|
||||||
(bytevector-u8-set! v i (car l))))))
|
(bytevector-u8-set! v i (car l))))))
|
||||||
|
|
||||||
(define (bytevector->list v start end)
|
(define (bytevector . objs)
|
||||||
(do ((i start (+ i 1))
|
(list->bytevector objs))
|
||||||
(res '()))
|
|
||||||
((= i end)
|
|
||||||
(reverse res))
|
|
||||||
(set! res (cons (bytevector-u8-ref v i) res))))
|
|
||||||
|
|
||||||
(define (list->bytevector v)
|
|
||||||
(apply bytevector v))
|
|
||||||
|
|
||||||
(define (utf8->string v . opts)
|
(define (utf8->string v . opts)
|
||||||
(let ((start (if (pair? opts) (car opts) 0))
|
(let ((start (if (pair? opts) (car opts) 0))
|
||||||
|
|
Loading…
Reference in New Issue