Alternatives

p1|p2|

is a pattern object that represents any of the patterns pi.

Details

  • If a named pattern such as x_ appears in pi that are not used in a particular match, then the named pattern is taken to have a value that is a zero-length sequence Sequence[].

Examples

open allclose all

Basic Examples  (2)

Replace instances of either a or b:

Specify a function for several argument types:

Scope  (2)

Pick out integers or reals:

Replace in an association using alternative patterns:

Wolfram Research (1991), Alternatives, Wolfram Language function, https://reference.wolfram.com/language/ref/Alternatives.html.

Text

Wolfram Research (1991), Alternatives, Wolfram Language function, https://reference.wolfram.com/language/ref/Alternatives.html.

BibTeX

@misc{reference.wolfram_2021_alternatives, author="Wolfram Research", title="{Alternatives}", year="1991", howpublished="\url{https://reference.wolfram.com/language/ref/Alternatives.html}", note=[Accessed: 28-July-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_alternatives, organization={Wolfram Research}, title={Alternatives}, year={1991}, url={https://reference.wolfram.com/language/ref/Alternatives.html}, note=[Accessed: 28-July-2021 ]}

CMS

Wolfram Language. 1991. "Alternatives." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Alternatives.html.

APA

Wolfram Language. (1991). Alternatives. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Alternatives.html