Skip to main content

simple-vector

simple-vector Type

Supertypes:

simple-vector, vector, simple-array, array, sequence, t

Description:

The type of a vector that is not displaced to another array, has no fill pointer , is not expressly adjustable and is able to hold elements of any type is a subtype of type simple-vector.

The type simple-vector is a subtype of type vector, and is a subtype of type (vector t).

Compound Type Specifier Kind:

Specializing.

Compound Type Specifier Syntax:

(simple-vector [size])

Compound Type Specifier Arguments:

size—a non-negative fixnum, or the symbol *. The default is the symbol *.

Compound Type Specifier Description:

This is the same as (simple-array t (size)).

Expanded Reference: simple-vector

The simple-vector Type

A simple-vector is a one-dimensional simple array with element-type t. It has no fill pointer, is not adjustable, and is not displaced. The vector function always creates simple vectors.

(typep (vector 1 2 3) 'simple-vector)
=> T

(typep (make-array 5) 'simple-vector)
=> T

(typep #(a b c) 'simple-vector)
=> T

What Is Not a Simple Vector

Strings, bit vectors, adjustable vectors, and vectors with fill pointers are not simple vectors.

(typep "hello" 'simple-vector)
=> NIL

(typep #*10110 'simple-vector)
=> NIL

(typep (make-array 5 :fill-pointer 0) 'simple-vector)
=> NIL

Parameterized simple-vector Type

The simple-vector type can be parameterized by size.

(typep (vector 1 2 3) '(simple-vector 3))
=> T

(typep (vector 1 2 3) '(simple-vector 4))
=> NIL

Type Relationships

(subtypep 'simple-vector 'vector)
=> T
=> T

(subtypep 'simple-vector 'simple-array)
=> T
=> T

;; svref requires a simple-vector
(svref (vector 'a 'b 'c) 1)
=> B