# Tagged Questions

Questions about functions which maintain an expression in unevaluated form, including the use and behavior of Hold, HoldForm, HoldComplete, and HoldPattern. Also questions concerning the attributes HoldFirst, HoldRest, HoldAll, etc.

2k views

### Replacement inside held expression

I wish to make a replacement inside a held expression: f[x_Real] := x^2; Hold[{2., 3.}] /. n_Real :> f[n] The desired output is ...
2k views

### How to pass a symbol name to a function with any of the Hold attributes?

Given a function with the attribute HoldFirst, HoldAll or similar, and a variable, list, how ...
2k views

### Changing Values in an Association using Map

I am trying to change the value of one key in an association based on the value of another key in that association. So if my association starts as: ...
815 views

### How to inject an evaluated expression into a held expression? [duplicate]

I know that there are methods to structurally manipulate held expressions (discussed e.g. here), but I failed to apply those for this particular problem: ...
452 views

### Prevent graphics render inside held expression

Assuming each odd line is input I would like the even lines to be the output of the following lines. In the above the Graphics are inside ...
284 views

### Held keys in associations

Jacob Akkerboom commented: Note that PositionIndex does work correctly with held expressions, whereas this is a bit painful to implement using ...
790 views

### Displaying a series obtained by evaluating a Taylor series

Description of problem I would like to use Mathematica to display the series obtained by substituting a value for $x$ in a Taylor series expansion. The terms of the series will be rational numbers, ...
215 views

### Hold expression with RandomInteger

One more question for today: I'm trying to show two random integers with a plus (+) sign between them, in an unevaluated form. I know how Hold and HoldForm work, but they hold everything, including ...
195 views

### Converting StringJoin to StringForm inside Hold

Let's say I have a piece of code: Hold[{code1, "asdad " <> ToString[testa] <> " adsd " <> ToString[testb], code2}] (*MWE ofc*) ...
321 views

### Pattern does not match with Orderless head

Why does the following pattern matching not succeed? ...
270 views

### HoldForm[Operator ##] on some list

Recently in response to this question Mr.Wizard suggested an unusual way to summing numbers. This doesn't seem to be documented. ...
1k views

### Replace symbols with values without evaluation

If I have assigned values to a, b and c: a=7; b=5; c=6; ...
531 views

### Get the name of a symbol passed to a function

I'm trying to get the name of a symbol passed to a function with this: f[x_] := {SymbolName[x], x} SetAttributes[f, HoldFirst] x = 5; f[x] But ...
307 views

### Why is this expression being held, and how can I evaluate it?

I can't figure out why an expression isn't evaluating, even though there's no Hold* in its FullForm: ...
338 views

### Is there a more Mathematica-y way to label these plots?

I am studying an infinite square well in the context of quantum mechanics. ...
167 views

### Passing an unevaluated part of an association to a function

I'm making a UI widget that controls sound volume on a speaker using a slider, e.g.: ...
316 views

### HoldForm does not Hold Form for fractions sometimes

I'm facing a strange behavior of HoldForm. I need to display 1/2*3/4 in LaTeX like this : $$\frac{1}{2} \times \frac{3}{4}$$ ...
79 views

### MatchQ failing in some cases with Hold [duplicate]

Could someone clarify why the first of these MatchQ finds a match whereas the second does not? (I'm using version 10.0, in case that matters.) ...
215 views

### How to join held Lists?

Let's say I have a = Hold@{2+2} b = Hold@{4+4} How can I get Hold@{2+2,4+4} ie join the two held lists ? More ...
185 views

### direct assignment to the element in a Table

I have already asked a related question here why set values in this way doesn't work? But I think I have to write the question which I encountered explicitly? ...
158 views

### Getting terms and only evaluate specific parts

I want to expand the expression but I do not want it to evaluate. Sum[(HoldForm[1/(2 # - 1) - 1/(2 # + 1)] &)[i], {i, 1, 6}] However if you evaluate this you ...
294 views

### Plot, HoldAll and the color problem

I have a similar problem as posted in Difference in Plot when using Evaluate vs when not using Evaluate, however due to a numerical evaluation I cannot use ...
251 views

### Why are the attributes of Plot changing?

In version 9, with a newly started Mathematica session, try the following code: ...
238 views

### Creating a custom context with a Hold construct

I'm trying to create a function "InContext" to execute a piece of code inside a certain context (and to return the result of evaluating that piece of code). One approach is to place the code inside a ...
433 views

### Can't inject EncryptedObject

Bug present from 10.0 to 10.3.1 and fixed in 10.4.0 !! Here are minimal examples: ...
367 views

### Replacing parts of a held expression with held parts of another expression

I'm applying the Trott-Strzebonski technique in order to replace inside a held expression. ...
628 views

### How to properly inject iterators into table? [duplicate]

Goofing off on a prior question, I was fiddling with other methods, which led me to the need to inject a constructed set of iterators into a table construct. Now, ...
481 views

### When should I, and when should I not, set the HoldAll attribute on a function I define?

I have seen a number of examples on this site (such as in syntax highlighting and checking evaluation status) in which functions definitions are preceded with ...
641 views

### Make function return unevaluated equation

I have made this function which outputs the equation of a nth degree polynomial: ...
96 views

### Pattern matching an expression involving Times

I'm trying to write a Mathematica function that will format expressions according to my preferences, for example displaying (5 c x)/Sqrt[2] as ...
335 views

### Concatenating strings, unevaluated expressions and evaluated expressions/values

Maybe this is something very simple to some of you. Anyway, I think this can be useful to many others like me. I would like to build an output that involves strings, unevaluated expressions and ...
131 views

### Pattern matching to head with HoldFirst

I want to define a function that only operates on expressions with a head from a given list, such as f[expr:(_And|_Or)] := Print["LHS is ", expr[[1]]]; This of ...
138 views

### Need to take infinite sum of residues, is there a way to choose the order of operations for ReleaseHold?

I'm computing an infinite sum of residues. I want to do something like this: ...
139 views

### Extracting variables from Hold expression

For example I have some global assignments x=1;y=2;z=3 and an expression Hold[x*y/z]. How can I now extract variables ...
199 views

### How to evaluate some parts of an expression inside Hold? [duplicate]

I want to return a Hold expression but with some parts pre-evaluated. The easiest way to explain this is probably through code example. Here is what I have ...