diff --git a/bytevector-tests.scm b/bytevector-tests.scm index afc7b20b..99bf4b18 100644 --- a/bytevector-tests.scm +++ b/bytevector-tests.scm @@ -22,6 +22,6 @@ (let ((x 1)) (define a #u8(1 2 3 4 5)) (define b #(1 2 3 4 5)) - (write (Cyc-bytevector-copy a 2 4)) ; =⇒ #u8(3 4) + (write (bytevector-copy a 2 4)) ; =⇒ #u8(3 4) (write b) ) diff --git a/scheme/base.sld b/scheme/base.sld index bddc239a..68c10495 100644 --- a/scheme/base.sld +++ b/scheme/base.sld @@ -152,6 +152,7 @@ inexact eof-object syntax-error + bytevector-copy ;;;; ; Possibly missing functions: @@ -159,7 +160,6 @@ ; ; byte vectors are not implemented yet: ; bytevector ; bytevector-append -; bytevector-copy ; bytevector-copy! ; bytevector-length ; bytevector-u8-ref @@ -700,6 +700,11 @@ (loop (+ i 1) (cons (vector-ref vec i) lst)))))) (loop start '()))) + (define (bytevector-copy bv . opts) + (letrec ((len (bytevector-length bv)) + (start (if (> (length opts) 0) (car opts) 0)) + (end (if (> (length opts) 1) (cadr opts) len))) + (Cyc-bytevector-copy bv start end))) (define (vector->string vec . opts) (let ((lst (apply vector->list (cons vec opts)))) (list->string lst)))