HoldPattern
HoldPattern[expr]
is equivalent to expr for pattern matching, but maintains expr in an unevaluated form.
Details
- HoldPattern has attribute HoldAll.
- The left‐hand sides of rules are usually evaluated, as are parts of the left‐hand sides of assignments. You can use HoldPattern to stop any part from being evaluated.
Examples
Basic Examples (4)
Set up a pattern whose left-hand side is kept unevaluated:
Make a definition without the argument of f being evaluated:
Log[a,b] autoevaluates to Log[b]/Log[a], so there is a match:
Cases[e,patt->rhs] finds elements that match patt; use HoldPattern to find rules:
Text
Wolfram Research (1996), HoldPattern, Wolfram Language function, https://reference.wolfram.com/language/ref/HoldPattern.html.
CMS
Wolfram Language. 1996. "HoldPattern." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HoldPattern.html.
APA
Wolfram Language. (1996). HoldPattern. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HoldPattern.html