Skip to content

IsVector ​

Tests whether list is a rank-1 List, optionally with every element satisfying test.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageVectorQ✓
IsVector(list)True if list is a List none of whose elements is itself a List
IsVector(list, test)as above, and test holds of every element
Typed signatures
TypePackageApplies
(any, function?) -> booleancombinatoricsalways

Domain: Collections

Details
  • A List containing a List (even a ragged one) is a matrix shape, not a vector — False.
  • A lazy ordered collection such as Range(1,10)Range(1, 10) stands for the List it evaluates to.
  • test is applied via Apply, same calling convention as a Function literal passed to Select/Map.

Examples

Basic #
live ↗
InIsVector([1,2,3])\mathrm{IsVector}(\bigl\lbrack1, 2, 3\bigr\rbrack)OutTrue\mathrm{True}

A flat list is a vector, whatever its entries

live ↗
InIsVector([a,b,c])\mathrm{IsVector}(\bigl\lbrack a, b, c\bigr\rbrack)OutTrue\mathrm{True}

A column of one-element lists is a matrix, not a vector

live ↗
InIsVector([[1],[2]])\mathrm{IsVector}(\bigl\lbrack\bigl\lbrack1\bigr\rbrack, \bigl\lbrack2\bigr\rbrack\bigr\rbrack)OutFalse\mathrm{False}

An undefined symbol is not known to be a vector

live ↗
InIsVector(vector)\mathrm{IsVector}(\mathrm{vector})OutFalse\mathrm{False}
Scope #
live ↗
InIsVector([[1,2],[3,4]])\mathrm{IsVector}(\bigl\lbrack\bigl\lbrack1, 2\bigr\rbrack, \bigl\lbrack3, 4\bigr\rbrack\bigr\rbrack)OutFalse\mathrm{False}
live ↗
InIsVector(3)\mathrm{IsVector}(3)OutFalse\mathrm{False}
live ↗
InIsVector([2,4,6],IsEven)\mathrm{IsVector}(\bigl\lbrack2, 4, 6\bigr\rbrack, \mathrm{IsEven})OutTrue\mathrm{True}
live ↗
InIsVector([2,3,6],IsEven)\mathrm{IsVector}(\bigl\lbrack2, 3, 6\bigr\rbrack, \mathrm{IsEven})OutFalse\mathrm{False}

The optional test must hold for every entry; exact integers fail it

live ↗
InIsVector(1..10,IsMachineNumber)\mathrm{IsVector}(1..10, \mathrm{IsMachineNumber})OutFalse\mathrm{False}
live ↗
InIsVector(1..10,IsInteger)\mathrm{IsVector}(1..10, \mathrm{IsInteger})OutTrue\mathrm{True}
live ↗
InIsVector(N(1..10),IsMachineNumber)\mathrm{IsVector}(N(1..10), \mathrm{IsMachineNumber})OutTrue\mathrm{True}
live ↗
InIsVector([1,π,sin⁡(1),2],_1⁡↦IsNumeric(_1⁡)∧ℑ(_1⁡)=0)\mathrm{IsVector}(\bigl\lbrack1, π, \sin(1), \sqrt{2}\bigr\rbrack, \operatorname{\_1}↦\mathrm{IsNumeric}(\operatorname{\_1})∧\Im(\operatorname{\_1})=0)OutTrue\mathrm{True}
Properties #

Undefined symbols are not known to be vectors

live ↗
In[IsVector(vec),IsVector(expr)]\bigl\lbrack\mathrm{IsVector}(\mathrm{vec}), \mathrm{IsVector}(\mathrm{expr})\bigr\rbrackOut[False,False]\bigl\lbrack\mathrm{False}, \mathrm{False}\bigr\rbrack
About
Examples13
Checked againstWolfram Language 13 agree
CrosswalkWolfram Language

See also: IsMatrix, IsArray