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.

learn more… | top users | synonyms

10
votes
2answers
260 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 ...
8
votes
4answers
231 views

How to inject unevaluated list of Unique into a RuleDelayed?

I am writing a function that constructs a rule which has Unique[] in the RHS. Here is a simplified segment of code ...
11
votes
1answer
190 views

How to see a code preview (in Experimental`Explore[] or related GUI)

I have been messing around with built in Experimental`Explore[] function. You can call the function in Mathematica yourself to see what it looks like. It is a GUI ...
1
vote
1answer
28 views

ReleaseHold NIntegrate after Replace variable

I would like to calculate the sum of square of two integral(Ex and Ey). I first hold this two integral because two variables(tx, ty) are not specified.Then, I replace tx,ty and releasehold ...
5
votes
4answers
242 views

Calculating N-th step of recurrent sequence

I am figuring out how to calculate $N$-th step of a square root approximation sequence: $$x_{n+1} = {1 \over 2} (x_{n} + a/x_n),$$ where $a$ is a number the root of which is to be found and $x_1$ is ...
20
votes
3answers
380 views

Can't inject EncryptedObject

Bug introduced with Encrypt in 10.0 Persisting through 10.3.1 or later Here are minimal examples: ...
0
votes
1answer
49 views

Alter evaluation order when applying scalar multiplication to function

Consider the following program: g = 2f; g[x] (* (2f)[x] *) Is there any way I can change the above expression to have it return ...
0
votes
1answer
96 views

Replace variable with # and pass function body as an argument to a function

I have a very simple problem, which I would like to make a bit general, but none of my naive approaches have worked yet. This is what I want to do step by step: Define a parameter: ...
8
votes
2answers
131 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.: ...
14
votes
0answers
156 views

Defer, Hold, Unevaluated, Inactivate — which one when?

What are some guidelines on which function to select from among the superficially similar functions Defer, Hold, ...
3
votes
1answer
53 views

Prevent expression from evaluation in function when using `ToString `

I defined function fhold Clear[fhold] SetAttributes[fhold, HoldAll] fhold[para_List] := ToString[para]; What I want is that ...
2
votes
1answer
104 views

How to properly define this function of function

I encountered real problem at first, and here is the toy example variable argument stored some expression that is generated from other parts of the program. I ...
9
votes
1answer
145 views

Why there is only `HoldFirst` but no `HoldSecond`, `HoldThird`, …`HoldN`?

I feel that this must be a duplicate. But I just can't find such a post. Mathematica has HoldFirst, HoldRest, ...
4
votes
1answer
59 views

HoldForm -> InputForm without processing the contents

I have programmatically generated a large number of simple equations like 1+1/2. I need them to be 'unprocessed', so they've been run through ...
0
votes
2answers
105 views
5
votes
2answers
78 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 ...
3
votes
1answer
59 views

How to evaluate an expression via `LinkWrite` when the expression is only known at runtime?

*** Here's the original post... I'm setting up a secondary kernel in sandbox mode with LinkLaunch, and need to pass various expressions to it for evaluation. These ...
3
votes
1answer
67 views

Table generation with SetDelayed function [closed]

I would like to understand why the following two outputs differ: Let us define the following data set: ...
1
vote
1answer
55 views

How to achieve fun[Unevaluated[f][Unevaluated[x], Unevaluated[y]] in a more elegant way?

I have defined a function fun[f_[x_,y_]]. When I call it, I want to wrap everything by Unevaluated: ...
7
votes
2answers
262 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. ...
2
votes
1answer
60 views

Manipulating unevaluated expressions in nested function calls

This is a follow-up to my earlier question: Passing an unevaluated part of an association to a function I'm trying to create a modular dashboard that controls sound volume of an audio system ...
1
vote
0answers
21 views

Use functions to call a named object [duplicate]

Now I have several interpolation functions called x30, x50, z30, z50...... I wish to write a function to call these function by inputing x or z and numbers automatically, and assign a argument x to ...
9
votes
1answer
110 views

FullSimplify Produces Result that Includes Hold

Bug fixed in 10.2.0 In the course of developing a solution to Question 79183, I solved the equation ...
20
votes
2answers
757 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: ...
2
votes
1answer
112 views

How to extract a variable names (not values) from a list of transformation rules?

I am trying to extract variable names from a list of transformation rules mapping = {var1 -> 'val1', var2 -> 'val2' }. Variables ...
2
votes
1answer
198 views

Evaluation of the second argument to NIntegrate

The expression Integrate[x^2, Flatten[{{x},{1,2}}]] evaluates properly, to $\frac{7}{3}$. However, ...
6
votes
1answer
70 views

How to force evaluation of an expression with Part left unnevaluated?

My goal is to minimize a real valued multi-variable function averageFreeEnergyDensity. The function accepts an integer argument ...
2
votes
1answer
158 views

Nested If statement with unevaluated arguments

I have a list of boolean functions {f1, f2, f3, ...} that take a value and return True or ...
12
votes
7answers
606 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, ...
1
vote
1answer
90 views

Printing names of indexed variables instead of values

I'd like to display only the variable (indexed variable) name (in symbol form, not in string form) instead of its value in Mathematica. Say I have a variable foo[i] ...
1
vote
1answer
61 views

How to prevent automatic simplification in InputField?

Here is a basic example: {InputField[Dynamic[x]], Dynamic[x]} This code generates an input box with and dynamic display. What is disturbing me is that when ...
1
vote
1answer
134 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 ...
0
votes
0answers
12 views

why does a ReplaceAll stop Plot from cycling colors? [duplicate]

Suppose I Plot[{a x^2, a x^3} /. {a -> 2}, {x, 0, 1}]. Then the expressions plot, but the colors do not cycle. If I Evaluate ...
4
votes
3answers
153 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 ...
1
vote
0answers
69 views

How to substitute inside Hold? How to create table of summation (with Sigma symbol) expressions? [duplicate]

I would like to create table of summation expressions, which are not evaluated, but summation limits are substituted. I can't accomplish this so far. If I write I get summation expanded. If I ...
5
votes
4answers
279 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} $$ ...
1
vote
2answers
79 views

How to Hold/Defer only one (only given) level?

Is it possible to Hold/Defer some of outer expressions, having evaluates inner ones? For example, I want to prepare a table of expression values, like this ...
15
votes
4answers
420 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 ...
31
votes
3answers
1k 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: ...
0
votes
0answers
42 views
5
votes
4answers
304 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 ...
1
vote
2answers
108 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 ...
12
votes
2answers
756 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, ...
0
votes
3answers
99 views

Create polynomials from Series

This question actually doesn't have quite a lot to do with the Series function, but I don't know how to describe my problem. So here's the thing. I'm trying to ...
3
votes
2answers
186 views

Converting unevaluated lists to strings

I have a list like l = {2 - 3, 12 - 4, Times, aab} I want to end up with {"2-3", "12-4", "Times", "aab"} I have tried ...
1
vote
1answer
96 views

Retain original form of formatted equation [duplicate]

I am having trouble getting Mathematica to retain my original equation form. For example: As you can see, even though I use HoldForm, it still changes the style of my equation. Very frustrating.
13
votes
4answers
343 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. ...