Conditionals

Mathematica's symbolic character allows a powerful unification of the notion of conditionals in programming and in mathematics.

ReferenceReference

Testing Expressions »

Equal(==) ▪ Unequal(!=) ▪ SameQ(===) ▪ And(&&) ▪ IntegerQ ▪ ...

Procedural Conditionals

If test if a condition is true, false, or of unknown truth value

Which test which of a sequence of conditions are true

Switch switch based on a value, with patterns allowed

Mathematical Function Conditionals »

Piecewise an arbitrary piecewise function

ConditionalExpression expression defined under condition

UnitStep ▪ Sign ▪ Mod ▪ Floor ▪ Boole ▪ DiscreteIndicator ▪ ...

Pattern-Based Conditionals »

Replace replace an expression if a rule applies

Condition (/;) — specify an arbitrary condition for a pattern to match

Functional Programming Conditionals »

NestWhile ▪ TakeWhile ▪ ...

List-Based Conditionals »

Select ▪ Cases ▪ Pick ▪ ...

Program Execution Conditionals

Check ▪ TimeConstrained ▪ MemoryConstrained

New to Mathematica? Find your learning path »
Have a question? Ask support »