Testing Expressions

Wolfram Language symbolic expressions can represent an immense range of types of objects. The Wolfram Language provides a rich collection of functions to test expressions. Functions that "ask a question" have names that end in Q. They return (RefLink[True, paclet:ref/True]) for an explicit true answer, and (RefLink[False, paclet:ref/False]) otherwise.

Equality & Inequality

(RefLink[Equal, paclet:ref/Equal]) ((RefLink[==, paclet:ref/Equal])), (RefLink[Unequal, paclet:ref/Unequal]) ((RefLink[!=, paclet:ref/Unequal])) — numerical equality

(RefLink[SameQ, paclet:ref/SameQ]) ((RefLink[===, paclet:ref/SameQ])), (RefLink[UnsameQ, paclet:ref/UnsameQ]) ((RefLink[=!=, paclet:ref/UnsameQ])) — literal symbolic identity

(OrangeLink[Logical Combinations », paclet:guide/LogicAndBooleanAlgebra])

Operator Forms

Numerical Properties

(RefLink[NumberQ, paclet:ref/NumberQ]), (RefLink[MachineNumberQ, paclet:ref/MachineNumberQ]) — literal number, literal machine-precision number

(RefLink[NumericQ, paclet:ref/NumericQ]) — numeric quantity (consisting of numbers, numeric constants, and functions)

List-Oriented Tests

(RefLink[VectorQ, paclet:ref/VectorQ]), (RefLink[MatrixQ, paclet:ref/MatrixQ]) — vector, matrix, perhaps with elements of specified types

(RefLink[ArrayQ, paclet:ref/ArrayQ]) — full array of any depth

(RefLink[MemberQ, paclet:ref/MemberQ]) — test whether a pattern occurs in a list

Expression Tests

(RefLink[MatchQ, paclet:ref/MatchQ]) — test whether an expression matches a pattern

(RefLink[Order, paclet:ref/Order]) — canonical ordering of expressions

(OrangeLink[String Tests », paclet:guide/StringManipulation])