Skip to main content

arrayp

arrayp Function

Syntax:

arrayp object → generalized-boolean

Arguments and Values:

object—an object.

generalized-boolean—a generalized boolean.

Description:

Returns true if object is of type array; otherwise, returns false.

Examples:

(arrayp (make-array(2 3 4) :adjustable t)) → true 
(arrayp (make-array 6)) → true
(arrayp #\*1011) → true

(arrayp "hi") → true
(arrayp ’hi) → false
(arrayp 12) → false

See Also:

typep

Notes:

(arrayp object) (typep object ’array)

Expanded Reference: arrayp

Basic Usage

arrayp returns true if its argument is an array, false otherwise. Vectors, strings, bit vectors, and multi-dimensional arrays are all arrays.

(arrayp (make-array 5))
=> T

(arrayp (make-array '(2 3)))
=> T

(arrayp 42)
=> NIL

(arrayp 'hello)
=> NIL

Strings and Bit Vectors Are Arrays

Strings and bit vectors are specialized one-dimensional arrays, so arrayp returns true for them.

(arrayp "hello world")
=> T

(arrayp #*10110)
=> T

Vectors Created by vector Are Arrays

(arrayp (vector 1 2 3))
=> T

Lists and Other Non-Array Types

Lists, numbers, symbols, and other non-array objects return false.

(arrayp '(1 2 3))
=> NIL

(arrayp #\a)
=> NIL

(arrayp nil)
=> NIL

Equivalence to typep

(arrayp x) is equivalent to (typep x 'array).

(let ((a (make-array '(2 3))))
(eq (arrayp a) (typep a 'array)))
=> T