Condition
patt
/;
test is a pattern which matches only if the evaluation of test yields True. lhs
:>
rhs
/;
test represents a rule which applies only if the evaluation of test yields True. lhs
:=
rhs
/;
test is a definition to be used only if test yields True.
Example: The pattern x_
/;
x
>
0 represents an expression which must be positive. All pattern variables used in test must also appear in patt. Example: f[x_]
:=
fp[x]
/;
x
>
1 defines a function in the case when . See The Mathematica Book on the web:Section 2.3.5 and Section 2.5.8. See also: If, Switch, Which, PatternTest, Element.
Further Examples
|
|
|
|
 |
|
|