HoldForm

HoldForm[expr]

prints as the expression expr, with expr maintained in an unevaluated form.

Details

  • HoldForm allows you to see the output form of an expression without performing normal evaluation of the expression.
  • HoldForm has attribute HoldAll and performs no operation on its arguments.
  • HoldForm is removed by ReleaseHold. »
  • HoldForm is generated by default by Trace and related functions and can be inserted as a wrapper by such functions as ToExpression and Extract. »
  • Even though expr itself is not evaluated, HoldForm[expr] may still evaluate if expr is of the form f[args] and upvalues for f have been defined. »

Examples

open allclose all

Basic Examples  (3)

Addition in held form:

An unevaluated assignment:

An unevaluated power:

Evaluate the expression by applying ReleaseHold:

Scope  (2)

Display a sum of squares in unevaluated form:

View the unevaluated form of an extracted part:

Applications  (1)

Show a formula and its evaluation:

Properties & Relations  (8)

HoldForm displays without a wrapper:

See the FullForm expression:

Hold displays the held expression with a wrapper:

Use Evaluate to force evaluation of an argument of HoldForm:

Sequence splicing and Splice still happen inside HoldForm:

Use HoldCompleteForm to suppress even such transformations:

Upvalues work inside HoldForm:

They do not work inside HoldCompleteForm:

ReleaseHold removes one level of HoldForm:

HoldForm gives an object that is never evaluated:

Copy the output and paste it into an input cell. The 1+2 is still unevaluated:

Defer gives an object whose evaluation is merely deferred until it is explicitly given as Wolfram Language input:

Copy the output and paste it into an input cell. The 1+2 is evaluated:

HoldForm maintains expressions in unevaluated form, and all parts are inactive:

Inactivate maintains symbols in inactive form and allows parts of expressions to be inactive:

HoldForm can be used to freeze the result of ToExpression before it is evaluated:

Possible Issues  (1)

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

HoldForm[expr] is not equivalent to expr for pattern matching:

Only a literal HoldForm expression is matched:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2024_holdform, author="Wolfram Research", title="{HoldForm}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/HoldForm.html}", note=[Accessed: 15-January-2025 ]}

BibLaTeX

@online{reference.wolfram_2024_holdform, organization={Wolfram Research}, title={HoldForm}, year={1988}, url={https://reference.wolfram.com/language/ref/HoldForm.html}, note=[Accessed: 15-January-2025 ]}