Skip to main content
25 votes

Why is Unevaluated[#]& different from Unevaluated?

I thought that for any function f we could use "f" interchangeably with "f[#]&". That ...
Szabolcs's user avatar
  • 236k
25 votes
Accepted

What's the difference between these 2 associations?

Preamble The real problem here seems somewhat deeper than what the (mostly correct) observations in comments indicate. In Mathematica, a number of objects, which are so-called raw objects (including ...
Leonid Shifrin's user avatar
18 votes
Accepted

Why is Unevaluated[#]& different from Unevaluated?

The two are not equivalent. Even if f lacks special attributes. Assuming no special attributes are present, a function's arguments are always evaluated before the ...
user541686's user avatar
  • 1,317
18 votes
Accepted

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

The action of the symbol Unevaluated is due to a special rule within the evaluator that occurs at a very specific time during the evaluation process. ...
WReach's user avatar
  • 69.1k
17 votes
Accepted

How to uncompress strings safely (without any evaluation)?

This is definitely a bug. Here's a slightly simpler workaround than those suggested in the comments: Uncompress[str, HoldComplete] // InputForm Generally ...
Itai Seggev's user avatar
  • 14.2k
16 votes
Accepted

Pure functions are not functions?

A response to this comment: I understand that there are workarounds. I am wondering whether I am misinterpreting the manual. Yes. The use of the word "function" in the manual may be confusing ...
Szabolcs's user avatar
  • 236k
16 votes
Accepted

Easy printing of executable code

You could define a function similar to Echo with the difference that it won't evaluate its argument before printing. ...
Szabolcs's user avatar
  • 236k
16 votes

Why is Unevaluated[#]& different from Unevaluated?

The head Unevaluated is a symbol with the HoldAllComplete attribute. The head ...
John Doty's user avatar
  • 13.8k
16 votes
Accepted

Evaluated vs. unevaluated Association

Summary The confusion we observe here is largely due to ambiguous use of the symbol Association as an expression head. On the one hand, ...
WReach's user avatar
  • 69.1k
15 votes
Accepted

HoldPattern vs Unevaluated

HoldPattern is a persistent head that prevents evaluation of its argument(s) yet is transparent to pattern matching. Unevaluated...
Mr.Wizard's user avatar
  • 272k
14 votes
Accepted

What is the potential usage of ReplaceAllUnheld in Developer Utilities Package?

Thank you for bringing this function to my attention! It lets us use ReplaceAll without disturbing or even traversing held expressions. This is huge! I have ...
Mr.Wizard's user avatar
  • 272k
11 votes
Accepted

How to get a unevaluted expression from a compressed string?

You need to wrap the expression Unevaluated before passing it to Compress, which means defining your own function instead of ...
Pillsy's user avatar
  • 18.6k
11 votes
Accepted

Confusion about HoldFirst attribute of Set

The problem is not related to Set in general but to how Set works with Part on a left hand ...
Kuba's user avatar
  • 137k
11 votes

Expanding a sum without evaluating it

may be Sum[With[{i=i},HoldForm[i^2]],{i,1,5}] But this uses a wrapper. I do not think there is a way without using Hold and ...
Nasser's user avatar
  • 147k
11 votes
Accepted

Perform localized, evaluation-leak free replacements

Here's a way making use of Block to cause f to be inert: ...
b3m2a1's user avatar
  • 47k
11 votes
Accepted

How to write a simple interpreter / DSL with Wolfram Language?

The current status of this answer I intend to return back to this very exciting question with a better answer, when I have it, but for now there will be something here to get you started. General ...
Leonid Shifrin's user avatar
11 votes
Accepted

Getting terms and only evaluate specific parts of a series

times[{i_}] := i times[{i__}] := Inactive[Times][i] Sum[times@Table[2 i - 1, {i, n}]/times@Table[2 i, {i, n}], {n, 5}] If you prefer ...
xzczd's user avatar
  • 67.1k
11 votes

Why is Evaluate[] in Plot[] not necessary in some cases?

I thought this Q&A might be closed as too broad or needing input from WRI. But it's still open with no close votes. I suppose I can explain two things, which might provide the understanding why <...
Michael E2's user avatar
  • 239k
10 votes
Accepted

How do I insert OwnValues inside a held expression without evaluating it?

ClearAll[a, b]; a := 1 + 1 b = Sqrt Is this acceptable? ...
Kuba's user avatar
  • 137k
10 votes

Confusion about HoldFirst attribute of Set

Kuba's answer explains why the first form does not work, but it does not address why the second form does work. That has been discussed in other questions DownValue assignment using Apply Why is the ...
Mr.Wizard's user avatar
  • 272k
10 votes
Accepted

How to make Mathematica evaluate this integral

For integrals involving Gaussians, I've often found it to be more convenient to get integrals via the Expectation value of the ...
Jens's user avatar
  • 97.6k
10 votes
Accepted

How to convert input expression to FullForm String

You just put Unevaluated in the wrong spot: ...
Carl Woll's user avatar
  • 131k
10 votes
Accepted

How can I check if a function remains unevaluated?

check if a function remains unevaluated. Why not just check the head? func = Log[3 x]^5*Sec[3 x]; result = Integrate[func, x] ...
Nasser's user avatar
  • 147k
10 votes
Accepted

Unwanted Hold from recursive function

The Problem Your function definition does not have a "base case." When Mathematica attempts to evaluate f[5], it uses the function definition (called ...
Robert Jacobson's user avatar
10 votes
Accepted

Obtaining the terms of a summation alongside the result

Have you considered Block? s := Sum[2 x, {x, 0, 3}] {s, Block[{Sum = Table}, s]} ...
Mr.Wizard's user avatar
  • 272k
10 votes
Accepted

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

The coefficient you give for the diffusion operator is a scalar but you can give a matrix of coefficients. I think this is what you are looking for: ...
user21's user avatar
  • 40.1k
10 votes
Accepted

How to define a version of Table[] which localizes iteration variable by Module[]?

Here is one way to do this for arbitrary number of iterators: ...
Leonid Shifrin's user avatar
9 votes
Accepted

How do I restore HoldAll, HoldFirst, HoldRest attributes of Inactivated functions

Introduction I'm not aware of any way to hold evaluation of arguments in expression of form Inactive[f][arguments], which is how inactivated expressions look like. ...
jkuczm's user avatar
  • 15.1k
9 votes
Accepted

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

From the "Details" of the docs for HoldPattern The left-hand sides of rules are usually evaluated, as are parts of the left-hand sides of assignments. You can ...
Michael E2's user avatar
  • 239k
9 votes
Accepted

Extract held value from Association

Ironically, the probably simplest answer is literally Extract, just as in the question's title: ...
Leonid Shifrin's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible