Questions tagged [hold]

Questions about functions which maintain an expression in unevaluated form, including the use and behavior of Unevaluated, Hold~ functions, Inactive related functions or Hold~ attributes.

Filter by
Sorted by
Tagged with
0
votes
1answer
111 views

ReplaceThen and ReplaceAt - Cross between ReplacePart, Replace, and Extract — Request for Comment

REWRITE: Multiple edits were hurting clarity Overview: I'm doing some work involving injecting code into held expressions, and found that I was repeating myself in a couple areas related to the ...
4
votes
0answers
81 views

DynamicModule Error when assigning Nothing to variable

Assigning Nothing to a variable inside Module works as expected: ...
0
votes
1answer
80 views

Combination of Block and With - Unexpected results

I'm trying to use Block to prevent a function from executing. In this example, the function I'm trying to block will simply be ...
0
votes
2answers
63 views

Hold `outermost layer` of expression

In pursuit of a function to force unsimplified fractions forceden[x_,d_]:=Hold[Evaluate[Numerator[x]d/Denominator@x]/d]; There are many related functions (...
1
vote
1answer
61 views

Exploring curl of a gradient of a scalar function

Suppose I want to explore $\nabla \times \nabla V$ where $V$ is some scalar function. It basically results in a zero. But I would only know why if I solve it on paper. I wanted to use Mathematica for ...
0
votes
1answer
48 views

How to instruct internal function to evaluate arguments only after numerical values are plugged in?

For convenience, let me start with a simple example. The following code calculates the sorted eigenvalues of a 4x4 Hermitian matrix with a parameter x ...
3
votes
1answer
47 views

How to force Mathematica to output a function using its alternate pretty form when using Apply? [closed]

By default, Bra is an undefined function. Let's say I have defined Bra, Bra[a___]:=... such ...
3
votes
0answers
37 views

How to stop Quantity from evaluating

I'm trying to get an expression to display, without it evaluating it's internal arguments, but for some reason, when given the Quantity function, HoldForm doesn't seem to do what I expect: Code ...
1
vote
0answers
57 views

Avoiding the memory requirements of an accumulation of returned Nulls (etc)

There is an extensive but relatively old answer to a similar question here, and there are many Qs and As about avoiding using Table where possible. My problem is a mixture of the two: I have been ...
2
votes
1answer
41 views

How to “Hold” variables assigned value inside DSolve?

Consider the following ODE: a = 0.8; b = 8; v = DSolveValue[{ u[x] == a*(b* u'[x] + u''[x]), u[4.925] == 4, u'[4.925] == 0.625 }, u[x], x] which gives ...
0
votes
1answer
63 views

Hold the value of a variable

This is my code xyzzy = 1; Hold[xyzzy] // ToString // StringLength The output is 11. This 2nd one below. ...
5
votes
3answers
227 views

HoldForm does not prevent evaluation

I'm still relatively new here, and I'm not a native speaker. I hope, I don't make any obvious mistakes when asking this question. For instance, I simply had no idea how to title it accurately. I'm ...
2
votes
2answers
59 views

How to get the symbol name of a list element?

Let's say we have a list g with variable d as its element: Clear[g, d] g = {1,2,3,d} Now <...
0
votes
1answer
39 views

why mathematica Holds the Solve on the set of equations in the diagonal a matrix?

Say I have a simple function F[x_, y_, z_, r_, a_, b_, c_, d_] := (1 - a + b - (b/3) (c x + d (y + z + r))) x And I want to solve the set of equations given by: <...
1
vote
1answer
54 views

Order of evaluation

I am having a hard time figuring this out: ( sample ) I have any matrix which can have an arbitrarily large dimension. ...
1
vote
1answer
36 views

Extracting name of symbol (variable name) from within a function not working

Abstract: I use a pattern so often that I needed to make a function for constructing it. A function getName[...] for extracting name of variable and value only ...
2
votes
1answer
76 views

How to use the SymbolName of variables along with Map and pure function

I want to label each point of a Graphics3D with the simplest method as possible. I tried many solutions like this : ...
1
vote
0answers
35 views

How to return a variable name and value from within a self-contained function block?

Abstract: I have viewed other solutions on StackExchange but none actually address using a fully self-contained function to return name and value of a variable. The only function that works requires ...
5
votes
1answer
80 views

head of a sequence

Why does Head[Sequence[b, c]] return c[Symbol] and not Sequence? Why does ...
2
votes
2answers
79 views
0
votes
2answers
71 views

Releasing multiple nested Hold in a single expression simultaneously

Trivia: I need to take a coefficient list of a long list of complicated expressions of the form $\prod c_{ij} \left( p_{i,j}(x_1,x_2) \right)^n$ where $n$ is positive integer, and $i,j$ label ...
1
vote
1answer
49 views

The number 1 evaluates inside HoldForm sometimes

If I run the following code: ...
1
vote
2answers
47 views

Evaluating part of an expression, but delaying the rest

Say I have an expression g = x^2 + y^3; I tried writing this H[x_, y_] := Eigenvalues[Evaluate[{{0, g}, {g, 0}}]]; The ...
2
votes
1answer
89 views

Problem calling function defined with HoldFirst

V 12.1 on windows. I am trying to use nice function from a recent post How to directly get the TeXForm of each steps from Rubi? ps. to run MWE code below, requires Rubi package, which if you do not ...
0
votes
1answer
44 views

SetDelayed using local variables

I'm trying to define MakeBoxes for a bunch of functions all at once, but wish to do so within a loop as in the following example: ...
3
votes
1answer
52 views

Hold all the symbols from a huge list?

The two following codes work similarly: Num = 5; symbols = Hold[X1, X2, X3, X4, X5]; or ...
1
vote
0answers
35 views

How to replace expressions in a `HoldComplete` and then evaluate them? [duplicate]

Example: ...
0
votes
1answer
49 views

Keeping equations in terms of specific variable

I'm new to Mathematica and really struggling with something seemingly simple. I'm trying to do an integration and keep the results in terms of the symbol $T_1$ and $A_i$: $$ T_1=\frac{\text{pi} A_i}{...
1
vote
1answer
34 views

Help with Evaluation controll/hold all attributes?

I'm making a sort of symbolic derivator, which needs to take its formulas in unevaluated form. ...
2
votes
2answers
56 views

Evaluation Control for interpolating functions

I would like to find the root of the third component of an interpolating function, here e.g. a BezierFunction p: ...
0
votes
1answer
56 views

Making a list of Strings from the SymbolNames for a list of Graphics

Having generated a list of plots, such as plot01 = Plot[Sin[x], {x, 0, 6}]; plot02 = Plot[Cos[x], {x, 0, 6}]; plotList = {plot01, plot02} Then create strings ...
4
votes
2answers
40 views

RandomVariate on multidimensional Bernoulli array

Executing... Map[RandomVariate, Map[BernoulliDistribution, RandomReal[1, 5]]] yields the expected result, e.g. ...
4
votes
1answer
64 views

Custom function which behaves like `Evaluate`

Question Is there a way to define a function which evaluates itself regardless of HoldAll, HoldFirst, ... ? Background I'm ...
2
votes
3answers
97 views

How to hold the expression when using ToExpression with TeXForm

I know {1, 1} // Apply[Defer@*Plus] can return 1+1 But if I want hold the form from TeXForm,what should I do? ...
1
vote
1answer
28 views

Define function that interleaves and then evaluates its arguments

I wish to define a function interleaveWithX[statements__] with behavior such that evaluating, for example, ...
8
votes
1answer
176 views

Why can't I use Inactive[D] in NDSolve?

I have a 2D rectangular domain with -L/2 < x < L/2 and 0 < y < D0, which is divided into two parts, with a ...
2
votes
1answer
62 views

LetL Breaks in ParallelEvaluate

This was a wild head-scratcher for me to hunt down, but I now am sure LetL is the culprit. Here's a small example: ...
2
votes
2answers
63 views

Vanishing function and Manipulate

Within Manipulate, I want to vanish certain controls if other controls satisfy a specific condition. The simplest case is to consider two checkboxes, ...
5
votes
1answer
134 views

Generate pattern held by HoldPattern

I am trying to match expressions that have factors with certain exponents. For instance, I would like to match as follows ...
1
vote
1answer
60 views

Map patterns to values

Suppose I have a list of named patterns: listofPatterns = {a_Integer, b_Real, c_?StringQ} I would like to have a mapping from a pattern to a certain value like: ...
9
votes
1answer
130 views

Why Optional in Set is not held by the HoldFirst attribute?

When evaluatingf[x_:x0] := x, x0 will be evaluated, regardless of the HoldAll attribute of <...
2
votes
1answer
69 views

Inactivate Controls within Manipulate

Given a certain Control object (checkbox, for example) within a Manipulate environment, my goal is to define another control ...
3
votes
1answer
57 views

Map a function to every given key of a nested association

Consider for example the nested association: myA = <|"d" -> <|"c" -> <|"a" -> 1, "b" -> 2|>|>|> It is easy to map a function to a ...
1
vote
0answers
61 views

Evaluate and PlotLegends

Related to this question here. I dont understand why Evaluated->True does not behave properly when also using PlotLegends. For example, running the code below ...
5
votes
4answers
304 views

How to Force Evaluation of Derivative in a Pure Function Definition

Let's say I have a function f1 = #^2 &; I want to calculate its derivative, perform some manipulations and make the result a pure function. I try ...
11
votes
1answer
206 views

Why does Unevaluated applied (@@) to a held expression not work?

I do not understand why Unevaluated sometimes does not work. Consider this expression: expr = Hold[a - a] Now let's say I ...
4
votes
3answers
93 views

Is it possible to use a previously defined value in subsequent definitions of a `Block`?

Is it possible to use a previously defined value in subsequent definitions of a Block? According to syntax coloration, this should work as expected, that is, ...
3
votes
7answers
283 views

Obtaining the terms of a summation alongside the result

I have a Sum expression: s := Sum[2x,{x,0,3}] As an exercise to explore the rewriting capabilities of the Wolfram Language, I ...
0
votes
1answer
95 views

Through does not have hold attribute?

Possibly Related to Unexpected behavior of KeyTake. Consider the following example, where I input #11 (last) is the misbehaving one. Am I missing something or do you agree there is a bug? ...
0
votes
0answers
54 views

After activating, inactive integral, output is coming same as input

I am trying to plot s w.r.t r (0,10). But because of inactive integral I am not able to. When I activate inactive integral, output is coming same as input. When I am trying to plot graph w.r.t r(0 to ...

1
2 3 4 5
7