The tag has no wiki summary.

learn more… | top users | synonyms

43
votes
3answers
1k views

Replace inside Held expression

I wish to make functional replacement inside Held expression like this: ...
27
votes
3answers
761 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: ...
19
votes
5answers
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 ...
17
votes
2answers
650 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: ...
17
votes
2answers
384 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 ...
15
votes
4answers
380 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 ...
13
votes
3answers
225 views

Can't inject EncryptedObject

Here are minimal examples: ...
13
votes
1answer
224 views

Why are the attributes of Plot changing?

In version 9, with a newly started Mathematica session, try the following code: ...
12
votes
7answers
560 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, ...
12
votes
4answers
314 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. ...
11
votes
3answers
198 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 ...
11
votes
2answers
682 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, ...
11
votes
2answers
267 views

How can you stop ordering of InputField entries?

I have: InputField[Dynamic[d]] Dynamic[d] If I enter e.g. a b x^5 h m the entry automatically gets sorted, as per screen ...
10
votes
1answer
332 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 ...
8
votes
4answers
184 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 ...
8
votes
2answers
163 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
1answer
219 views

Why does Plot[Hold[x], {x,0,1}] work?

It appears that, counter to my expectation, all of these (and probably many others) seem to work fine: ...
7
votes
6answers
204 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 ...
7
votes
3answers
177 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*) ...
6
votes
4answers
302 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. ...
5
votes
4answers
251 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 ...
5
votes
4answers
204 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} $$ ...
5
votes
3answers
229 views

Applying a function with the HoldAll attribute inside NestList

I'm trying to write an update function, which can be applied to a list and then to NestList it. As the function has to manipulate the given variable I figured I ...
5
votes
1answer
83 views

Why is NHoldFirst not propagated to symbolic derivatives?

I encountered a nasty problem that N cannot evaluate expressions containing a symbolic Derivative of a multi-parameter function ...
5
votes
0answers
49 views

FullSimplify Produces Result that Includes Hold

In the course of developing a solution to Question 79183, I solved the equation ...
4
votes
3answers
143 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 ...
4
votes
2answers
166 views

Confusing ReplaceRepeated & Hold

I've been bootstrapping myself to the very alien world of Mathematica and there came my first WTF moment: ...
4
votes
4answers
658 views

Replace symbols with values without evaluation

If I have assigned values to a, b and c: ...
4
votes
2answers
208 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. ...
3
votes
4answers
503 views

Make function return unevaluated equation

I have made this function which outputs the equation of a nth degree polynomial: ...
3
votes
3answers
93 views

Operations on expressions within Hold [duplicate]

I want to convert {Hold[1 + 2], Hold[3 + 4], Hold[5*6]} into Hold[{1 + 2, 3 + 4, 5*6}]. I have tried ...
3
votes
2answers
127 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 ...
3
votes
2answers
158 views

Stopping a head from evaluating more than once

While attempting to answer my own question, Is there a way to "hold" prefix / infix / postfix notation?, I came across the need to evaluate a recursive function only one level deep. For ...
3
votes
2answers
79 views

Confused with HoldForm in Postfix notation

Why does the following code produce different result? In my mental model, they should be the same. ...
3
votes
1answer
107 views

Why is held expression evaluated?

Context: I'm studying non-linear dynamics. As part of a bigger problem, I'd like to generate lists of the form {{deq, ic1}, {deq, ic2}, ...}, where ...
3
votes
1answer
122 views

How do I get the length of held list without evaluating the list?

I used Extract with Hold to retrieve a sublist containing expressions I didn't want evaluating, e.g. ...
3
votes
1answer
54 views

Table doesn't replace inside conditionals (If, Which) [duplicate]

This: Table[If[cond, y], {y, 1, 3}] outputs this: {If[cond, y], If[cond, y], If[cond, y]} The ...
2
votes
1answer
229 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 ...
2
votes
2answers
112 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 ...
2
votes
1answer
83 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 ...
2
votes
1answer
154 views

Applying rules to rewrite expressions that contain patterns

I'm trying to write a rule that can rewrite a pattern that exists in another expression. For some reason, this is proving to be more challenging than I expected ... most likely because I'm not totally ...
2
votes
1answer
244 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: ...
1
vote
2answers
491 views
1
vote
1answer
175 views

Passing a joined list of symbols for Module or Block to treat as its own local symbols

The Question I'd like to write a function which itself takes a list of symbols, e.g. Foo[{x, y, z}] to pass to Module ...
1
vote
1answer
44 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
47 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
2answers
70 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 ...