Condition
Condition(pattern, expr)
or
pattern /; expr
places an additional constraint on
pattern
that only allows it to match ifexpr
evaluates toTrue
.
Examples
The controlling expression of a Condition
can use variables from the pattern:
>> f(3) /. f(x_) /; x>0 -> tt
>> f(-3) /. f(x_) /; x>0 -> tf(-3)
Condition
can be used in an assignment:
>> f(x_) := p(x) /; x>0>> f(3)p(3)
>> f(-3)f(-3)
Implementation status
- ✅ - full supported