Hold[expr]
maintains expr in an unevaluated form.
Hold
Hold[expr]
maintains expr in an unevaluated form.
Details
- Hold allows you to use an expression that has not undergone normal evaluation.
- Hold has attribute HoldAll and performs no operation on its arguments.
- Hold is removed by ReleaseHold. »
- Hold[e1,e2,…] maintains a sequence of unevaluated expressions to which a function can be applied using Apply.
- Hold can be inserted as a wrapper by such functions as ToExpression and Extract. »
- Even though expr itself is not evaluated, Hold[expr] may still evaluate if expr is of the form f[args], and upvalues for f have been defined. »
Examples
open all close allBasic Examples (1)
Scope (1)
Applications (2)
Find the length of each expression in a held list without evaluation:
list = Hold[1 + 2, 2 3 4 5, 1 / 0, Quit[]];Apply[List, Map[Hold, list]]% /. Hold[e_] :> Length[Unevaluated[e]]Evaluate every sum (only) inside a held expression:
expr = Hold[{1 + 2, g[3 + 4, 2 3], f[1 + g[2 + 3]]}]pos = Position[expr, _Plus]val = Extract[expr, pos]ReplacePart[expr, Thread[pos -> val]]Properties & Relations (10)
Hold is a container with the attribute HoldAll:
Attributes[Hold]Hold[1 + 2]Use Evaluate to force evaluation of an argument of Hold:
Hold[Evaluate[1 + 1], 2 + 2]Unevaluated inside a held expression is not removed:
Hold[Unevaluated[1 + 1]]Sequence splicing still happens inside Hold:
Hold[Sequence[1 + 1, 2 + 2]]Use the container HoldComplete to suppress even such transformations:
HoldComplete[Sequence[1 + 1, 2 + 2]]Upvalues work inside Hold:
h/:Hold[h[x_]] := f[x]Hold[h[1 + 2]]They do not work inside HoldComplete:
h/:HoldComplete[h[x_]] := f[x]HoldComplete[h[1 + 2]]Substitution works inside Hold:
Hold[f[1 + 2]] /. f[x_] :> g[x]Insert into a held expression:
Insert[Hold[x + x], y, {1, 2}]ReleaseHold removes one level of Hold:
ReleaseHold[Hold[1 + 2]]HoldForm is like Hold but is normally not shown in the output:
HoldForm[1 + 2]FullForm[%]Hold can be used to freeze the result of ToExpression before it is evaluated:
ToExpression["1+1", InputForm, Hold]Tech Notes
Related Guides
Related Workflows
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), Hold, Wolfram Language function, https://reference.wolfram.com/language/ref/Hold.html.
CMS
Wolfram Language. 1988. "Hold." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Hold.html.
APA
Wolfram Language. (1988). Hold. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Hold.html
BibTeX
@misc{reference.wolfram_2026_hold, author="Wolfram Research", title="{Hold}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Hold.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_hold, organization={Wolfram Research}, title={Hold}, year={1988}, url={https://reference.wolfram.com/language/ref/Hold.html}, note=[Accessed: 12-June-2026]}