Patterns Involving Alternatives
|patt1|patt2|...||a pattern that can have one of several forms|
Specifying patterns that involve alternatives.
when its argument is either
The first two cases give
You can also use alternatives in transformation rules.
Here is another example, in which one of the alternatives is itself a pattern.
When you use alternatives in patterns, you should make sure that the same set of names appear in each alternative. When a pattern like matches an expression, there will always be a definite expression that corresponds to the object . If you try to match a pattern like , then there still will be definite expressions corresponding to and , but the unmatched one will be Sequence[ ].
is used to name the head, which can be either