Sascha Ziemann
2014-08-19 15:30:56 UTC
I am wondering if R7RS lacks a vector-insert.
If you want to write a vector-insert in R7RS you have to do:
- calculate the length of the new vector
- create a new vector with make-vector
- copy the old content with vector-copy to the beginning and the end
- copy the new content into the middle with vector-copy
This includes twice as much assignments as necessary, because first
make-vector initializes the new vector with unspecified values and after
that each element of the new vector is assigned by the vector-copy calls.
I think the only way to avoid this is to have a dedicated vector-insert.
Sascha
If you want to write a vector-insert in R7RS you have to do:
- calculate the length of the new vector
- create a new vector with make-vector
- copy the old content with vector-copy to the beginning and the end
- copy the new content into the middle with vector-copy
This includes twice as much assignments as necessary, because first
make-vector initializes the new vector with unspecified values and after
that each element of the new vector is assigned by the vector-copy calls.
I think the only way to avoid this is to have a dedicated vector-insert.
Sascha