ArrayQ

ArrayQ[expr]
gives True if expr is a full array or a SparseArray object, and gives False otherwise.

ArrayQ[expr,patt]
requires expr to be a full array with a depth that matches the pattern patt.

ArrayQ[expr,patt,test]
requires also that test yield True when applied to each of the array elements in expr.

DetailsDetails

  • In a full array all parts at a particular level must be lists of the same length.
  • ArrayQ[expr,1|2] tests whether expr is either a vector or a matrix.
  • ArrayQ[expr,_,NumberQ] tests whether expr is a numerical array at all levels.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

A vector of numbers is a full array:

In[1]:=
Click for copyable input
Out[1]=

A vector in which one element is itself a list is not a full array:

In[2]:=
Click for copyable input
Out[2]=

A ragged collection of nested lists is not a full array:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
Introduced in 2003
(5.0)