vectorref  access an element of a vector
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
SYNOPSIS
(vectorref vector k)
DESCRIPTION
Returns the contents of element
k
of
vector.
RETURN VALUES
Returns a single value; an object from the vector.
EXAMPLES
(vectorref '#(1 1 2 3 5 8 13 21) 5)
=> 8
(vectorref '#(1 1 2 3 5 8 13 21)
(exact
(round (* 2 (acos 1)))))
=> 13
APPLICATION USAGE
The specification of vectors does not actually require constant access
time, but in practice they are always implemented as flat arrays.
Therefore this procedure is used in algorithms that perform
randomaccess operations on arrays. Such algorithms would not have the
same time complexity if lists were used instead.
COMPATIBILITY
This procedure works the same everywhere.
ERRORS
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.
In particular,
k
must be an exact nonnegative integer less than the length of
vector.
 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.
SEE ALSO
makevector(3scm),
definerecordtype(7scm)
STANDARDS
R4RS,
IEEE Scheme,
R5RS,
R6RS,
R7RS
HISTORY
This procedure first appeared in R2RS, where the vector notation was optional.
AUTHORS
This page is part of the
schememanpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.