Skip to main content

simple-vector-p

simple-vector-p Function

Syntax:

simple-vector-p object → generalized-boolean

Arguments and Values:

object—an object.

generalized-boolean—a generalized boolean.

Description:

Returns true if object is of type simple-vector; otherwise, returns false..

Examples:

(simple-vector-p (make-array 6)) → true 
(simple-vector-p "aaaaaa") → false
(simple-vector-p (make-array 6 :fill-pointer t)) → false

See Also:

simple-vector

Notes:

(simple-vector-p object) (typep object ’simple-vector)

Expanded Reference: simple-vector-p

Basic Usage

simple-vector-p returns true if its argument is a simple vector -- a one-dimensional, non-adjustable, non-displaced array with element-type t and no fill pointer.

(simple-vector-p (vector 1 2 3))
=> T

(simple-vector-p (make-array 5))
=> T

(simple-vector-p 42)
=> NIL

Strings and Bit Vectors Are Not Simple Vectors

Even though strings and bit vectors are one-dimensional arrays, they have specialized element types and thus are not of type simple-vector.

(simple-vector-p "hello")
=> NIL

(simple-vector-p #*10110)
=> NIL

Vectors with Fill Pointers or Adjustability

Vectors with fill pointers are not simple vectors. Adjustable vectors may or may not be simple, depending on the implementation.

(simple-vector-p (make-array 5 :fill-pointer 3))
=> NIL

Relationship to Other Predicates

A simple vector satisfies vectorp and arrayp as well, but the reverse is not always true.

(let ((sv (vector 'a 'b 'c)))
(list (simple-vector-p sv)
(vectorp sv)
(arrayp sv)))
=> (T T T)

(let ((fv (make-array 5 :fill-pointer 0)))
(list (simple-vector-p fv)
(vectorp fv)
(arrayp fv)))
=> (NIL T T)