vector->list(3scm) Scheme Programmer's Manual vector->list(3scm)

vector->list, list->vector - conversion between vectors and lists

(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme base))              ;R7RS

(vector->list vector)
(vector->list vector start)         ;R7RS
(vector->list vector start end)     ;R7RS
(list->vector list)

The vector->list procedure returns a newly allocated list of the objects contained in the elements of vector.

The list->vector procedure returns a newly created vector initialized to the elements of the list list.

In both procedures, order is preserved.

R7RS
The vector->list procedure is limited to the elements between start (inclusive) and end (exclusive). These arguments default to 0 and the length of the vector, respectively.

Chez Scheme, Loko Scheme
The empty vector is a unique object, so (list->vector '()) does not return a newly allocated vector.

These procedures both return a single value; a vector object or a list.

(vector->list '#(dah dah didah))
            => (dah dah didah)
(list->vector '(dididit dah))
            => #(dididit dah)

These procedures work the same everywhere except for the start and end arguments, which are only present in the R7RS variant of vector->list.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
In particular, if list->vector is passed a cyclical list then the procedure may not terminate.

vector(3scm), list(3scm), list->string(3scm), vector->string(3scm)

R4RS, R5RS, R6RS, R7RS

These procedures first appeared in R2RS. They were left out of IEEE Scheme. But in spite of this, list->vector appears as an example in the standard.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2023-01-24