Function Repository Resource:

LabeledPrint

Source Notebook

Print an expression with a label of its unevaluated form

Contributed by: Joel Klein

ResourceFunction["LabeledPrint"][expr]

prints the unevaluated form of expr followed by its evalated form.

ResourceFunction["LabeledPrint"][expr,fmt]

applies a format like InputForm,OutputForm, etc. to the expression for printing its value.

Details and Options

ResourceFunction["LabeledPrint"] has the attribute HoldAllComplete.
ResourceFunction["LabeledPrint"] can be used to add debug output to a program.
The output of ResourceFunction["LabeledPrint"] is Null.

Examples

Basic Examples (2) 

Print the current value of $ContextPath with a label indicating what it is:

In[1]:=
ResourceFunction["LabeledPrint"][$ContextPath]

Print a labeled string in InputForm to show string characters and escape sequences:

In[2]:=
text = StringJoin[CharacterRange[0, 31]];
ResourceFunction["LabeledPrint"][text, InputForm]

Publisher

Joel Klein

Version History

  • 1.0.0 – 14 November 2019

Related Resources

License Information