Jeffrey B. Siegal <jbs@quiotix.com> wrote:
+---------------
| Rob Warnock wrote:
| > But, yes, that probably *is* the simplest/best way using the primitives
| > provided in the R5RS spec, since there's no "vector-copy" there. I suppose
| > you could that version with this one:
| >
| > (define (vector-copy old)
| > (let* ((len (vector-length old))
| > (new (make-vector len)))
| > (do ((i 0 (+ i 1)))
| > ((>= i len))
| > (vector-set! new i (vector-ref old i)))
| > new))
|
| Does this use something other than R5RS primitives?
+---------------
No, but it's more complicated and uses more mutation (side-effects)
than the simpler vector -> list -> vector version, and may run either
faster or slower than that version (for the various reasons I listed).
So unless it makes a significant difference (in a specific application
on a specific platform), I'd choose the simpler one.
-Rob
-----
Rob Warnock, 31-2-510 rpw3@sgi.com
SGI Network Engineering http://reality.sgi.com/rpw3/
1600 Amphitheatre Pkwy. Phone: 650-933-1673
Mountain View, CA 94043 PP-ASEL-IA