From e795b4a75a586ee4fd3e03c70f402734148a5167 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 3 Aug 2014 14:16:13 +0900 Subject: [PATCH] small refactor --- piclib/prelude.scm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/piclib/prelude.scm b/piclib/prelude.scm index d6c5ab89..00d77663 100644 --- a/piclib/prelude.scm +++ b/piclib/prelude.scm @@ -605,24 +605,24 @@ ;;; 6.9 bytevector -(define (bytevector . objs) - (let ((len (length objs))) +(define (bytevector->list v start end) + (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))) (do ((i 0 (+ i 1)) - (l objs (cdr l))) + (l list (cdr l))) ((= i len) v) (bytevector-u8-set! v i (car l)))))) -(define (bytevector->list v start end) - (do ((i start (+ i 1)) - (res '())) - ((= i end) - (reverse res)) - (set! res (cons (bytevector-u8-ref v i) res)))) - -(define (list->bytevector v) - (apply bytevector v)) +(define (bytevector . objs) + (list->bytevector objs)) (define (utf8->string v . opts) (let ((start (if (pair? opts) (car opts) 0))