This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / Built-in Functions / Programming / Pattern Matching /

Condition

FilledSmallSquare patt /; test is a pattern which matches only if the evaluation of test yields True.

FilledSmallSquare lhs :> rhs /; test represents a rule which applies only if the evaluation of test yields True.

FilledSmallSquare lhs := rhs /; test is a definition to be used only if test yields True.

FilledSmallSquare Example: The pattern x_ /; x > 0 represents an expression which must be positive.

FilledSmallSquare All pattern variables used in test must also appear in patt.

FilledSmallSquare Example: f[x_] := fp[x] /; x > 1 defines a function in the case when .

FilledSmallSquare lhs := Module[vars, rhs /; test] allows local variables to be shared between test and rhs. You can use the same construction with Block and With.

FilledSmallSquare See Section 2.3.5 and Section 2.6.8.

FilledSmallSquare See also: If, Switch, Which, PatternTest, Element.

FilledSmallSquare New in Version 1.

Further Examples