(setf vec (make-array 4 :initial-element nil))
(svref vec 0)
In the above snippet we create a vector of length 4 and access its elements by (svref vec ).
(vector 1 2 3 4 5)
In the above snippet we create a vector of length 5 using vector function. How do we access the elements of this vector? How svref is used for this vector?
The generic vector reference function is
aref
, the same as for all other arrays.Svref
is only for simple vectors, i. e. vectors withelement-type
t
, not adjustable, no fill-pointer, not displaced.By the way,
vector
does produce a simple vector, sosvref
should work for your second example, too.Other issues:
:initial-element
.