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

0
votes
0answers
36 views

Can “Part” be hold? [on hold]

I'm trying to define a function of which the length of the argument is undetermined. However, the exact form of this function depend on the length of the argument. And to save time, I have to evaluate ...
2
votes
1answer
77 views

Help on order of evaluation within plot function

it is my first time asking a question here so please let me know if there's anything I should be doing that I'm unaware of. I'm sure the answer to my question already exists on the site but I'm having ...
5
votes
0answers
120 views

Same input,different result? [duplicate]

Using this code,you can see,same input, but the output are different. So weird! If I copy this code here, it outputs normally. So what's the problem? Ps:I use ...
3
votes
3answers
93 views

Can I hold a condition in NMaximize/NMinimize?

I'd like to use NMaximize/NMinimize with the condition ...
1
vote
0answers
80 views

How to “INJECT” with holding Evaluation, specifically into a WhenEvent

I am importing a set of differential and stochastic equations from an external package, and want to use Mathematica to analyse this. I am struggling building the set of equations that I can use with ...
0
votes
0answers
23 views

Evaluating UnitConvert inside LogPlot

I imported several Physical Quantities with their units and doing single calculations with them works fine and return the right unit, which I can change by UnitConvert[]... For the LogPlot I made a ...
2
votes
2answers
42 views

Better alternative to Hold/ReleaseHold for postfix application of Monitor

Trying to Monitor a process using the postfix notation, as in Table[Pause[n/10], {n, 5}] // Monitor[#, n] & fails: the ...
8
votes
1answer
86 views

Matching HoldPattern expressions

My original problem is to delete all rules starts with a[1] from SubValues[a] For example, ...
1
vote
0answers
38 views

Pretty equations in HoldForm[]

I have been generating equations programmatically, resulting in lists that look like this: {Log[2,(4^4)^3, 3 (Mod[2,4] 4), Log[root[2, 3], 4^4]} where ...
19
votes
2answers
320 views
4
votes
2answers
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.) ...
3
votes
3answers
63 views

Replace variable with value prior to evaluating NIntegrate

The title says it all. Reading posts such as this however, I'm not seeing how to do this. This is the simplest example that can show my problem. ...
58
votes
3answers
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 ...
12
votes
7answers
626 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, ...
8
votes
3answers
179 views

Expand series unevaluated

I'm newbie in Mathematica. I'd like to obtain nice and verbose output for any series calculation. For example, given a simple sequence n*(-1)^(n-1) and ...
2
votes
1answer
56 views

Evaluate within Hold

When I do... p=3; HoldForm[Evaluate[p]-2] I get: Evaluate[p]-2 BUT I'd like to get: ...
9
votes
0answers
66 views

Is there a way to TagSet a HoldAllComplete function?

Let's say I want to overload the built-in function Lookup, to handle my data wrapped in myObject. One would use ...
22
votes
3answers
431 views

Can't inject EncryptedObject

Bug present from 10.0 to 10.3.1 and fixed in 10.4.0 !! Here are minimal examples: ...
9
votes
2answers
162 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.: ...
1
vote
1answer
39 views

Customized `ParallelTable` - Automate `ParallelSubmit` - Possibly an issue with `HoldAllComplete` attribute

Related to this question and in particular its answer I am trying to wrap everything into a new parallelTab function that takes into account some cost per job, ...
5
votes
5answers
268 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} = \frac12\left(x_{n} + \frac{a}{x_n}\right),$$ where $a$ is a number the root of which is to be found ...
2
votes
1answer
49 views

Recognition Power Head for numeric value

We know: Map[Head, {a, a^2, a^3}] (* {Symbol, Power, Power} *) and Map[Head, {2, 2^2, 2^3}] all of them will be known as ...
18
votes
1answer
223 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, ...
10
votes
2answers
275 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
295 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 ...
12
votes
1answer
202 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
38 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 ...
0
votes
1answer
52 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
98 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: ...
3
votes
1answer
62 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
117 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
149 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
64 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
125 views
6
votes
2answers
95 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
62 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
77 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
269 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
63 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
113 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 ...
21
votes
2answers
799 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
119 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
210 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
75 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 ...
3
votes
1answer
197 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 ...
1
vote
1answer
116 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] ...