Added bytevector-copy

This commit is contained in:
Justin Ethier 2016-03-24 02:02:04 -04:00
parent 2aa9276132
commit c1b98df688
2 changed files with 7 additions and 2 deletions

View file

@ -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)
)

View file

@ -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)))