From ca66291d93e8463e0795bb41722bd1cafe45fb1c Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 17 Nov 2013 18:35:45 +0900 Subject: [PATCH] vector<->list conversion --- piclib/built-in.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 9efacf4f..ae6d6bca 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -390,6 +390,20 @@ v) (vector-set! v i (car l)))))) +(define (vector->list vector . opts) + (let ((start (if (pair? opts) (car opts) 0)) + (end (if (>= (length opts) 2) + (cadr opts) + (vector-length vector)))) + (do ((i start (+ i 1)) + (res '())) + ((< i end) + (reverse res)) + (set! res (cons (vector-ref vector i) res))))) + +(define (list->vector list) + (apply vector list)) + (define (vector-copy! to at from . opts) (let ((start (if (pair? opts) (car opts) 0)) (end (if (>= (length opts) 2)