VectorQ

VectorQ[expr]
gives True if expr is a list or a one-dimensional SparseArray object, none of whose elements are themselves lists, and gives False otherwise.

VectorQ[expr, test]
gives True only if test yields True when applied to each of the elements in expr.

DetailsDetails

ExamplesExamplesopen allclose all

Basic Examples (3)Basic Examples (3)

Test whether an object is a vector:

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

These are not vectors:

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

Use specific tests to generalize or specialize:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
New in 1 | Last modified in 5
New to Mathematica? Find your learning path »
Have a question? Ask support »