Scheme Programmer's Manual

NAME

vector - make a new vector with the given arguments

LIBRARY

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

SYNOPSIS

(vector obj ...)

DESCRIPTION

Returns a newly allocated vector whose elements contain the given arguments.

IMPLEMENTATION NOTES

Some implementations allocate a new object every time this procedure returns an empty vector. One such implementation is Chicken 5.2.0. Other implementations, like Chez Scheme 9.5, return the same empty vector object every time.

RETURN VALUES

Returns a newly allocated vector.

If this procedure is called without arguments it returns the empty vector, which may or may not be newly allocated.

EXAMPLES

(vector 'a 'b 'c) => #(a b c)

; Newly allocated vectors are mutable: (define x (vector 'a 'b 'c)) (vector-set! x 0 'A) x => #(A b c)

; Vector literals are immutable (but implementations may or ; may not catch this error): (define x '#(a b c)) (vector-set! x 0 'A) => error

; Implementations are free to choose if they use one or ; multiple objects to represent the empty vector. (eq? (vector) (vector)) => #t or #f

APPLICATION USAGE

Applications should avoid calling this procedure with an unknown number of arguments. The arguments are passed on the stack, which may not be able to handle a very large number of arguments. A better way to convert a list to a vector is with the list->vector(3) procedure.

COMPATIBILITY

The vector procedure enjoys wide support across Lisp dialects.

ERRORS

This procedure does not raise exceptions, but it may cause an out-of-memory condition which generally cannot be handled.

SEE ALSO

list->vector(3), make-vector(3), list(3)

STANDARDS

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

AUTHORS

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

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
IMPLEMENTATION NOTES
RETURN VALUES
EXAMPLES
APPLICATION USAGE
COMPATIBILITY
ERRORS
SEE ALSO
STANDARDS
AUTHORS
Return to Main Contents