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 any occurrences of that named pattern will be deleted from the right-hand side of any replacement rule.

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.

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_alternatives, organization={Wolfram Research}, title={Alternatives}, year={1991}, url={https://reference.wolfram.com/language/ref/Alternatives.html}, note=[Accessed: 21-November-2024 ]}