Mathematica 9 is now available

Documentation / Mathematica / Built-in Functions / New in Version 3.x / Programming /

HoldPattern

FilledSmallSquare HoldPattern[expr] is equivalent to expr for pattern matching, but maintains expr in an unevaluated form.

FilledSmallSquare HoldPattern has attribute HoldAll.

FilledSmallSquare 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.

FilledSmallSquare Example: expr /. HoldPattern[Integrate[y_, x_]] -> rhs transforms any subexpression of the form Integrate[y_, x_] in expr. Without the HoldPattern, the Integrate[y_, x_] in the rule would immediately be evaluated to give x_ y_, and the replacement would not work.

FilledSmallSquare Example: f[HoldPattern[Integrate[y_, x_]]] := value can be used to make an assignment for expressions of the form f[Integrate[y_, x_]]. Without HoldPattern, the Integrate function would be evaluated at the time of assignment.

FilledSmallSquare See Section 2.6.6.

FilledSmallSquare See also: Hold, Verbatim.

FilledSmallSquare New in Version 3.

Further Examples



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.