Skip to main content

All Questions

4 votes
4 answers
191 views

How to use replacement rules in a named expression before a sub-expression evaluates?

I have a named expression: expr := a + b. a and b are also named expressions. Let's say <...
Borislav Stanimirov's user avatar
3 votes
1 answer
98 views

Prevent argument substitution in held expression when injecting into unevaluated code

I want to write a custom sow/reap pair to wrap any piece of code in sow[code] and call reap ...
István Zachar's user avatar
10 votes
2 answers
1k views

What is the Difference Between Rule (->) and RuleDelayed (:>)?

I am new to Mathematica so this question may seem rudimentary. Sorry for that! :) I want to implement the well-known property of Kronecker's Delta $$\Sigma_{i=1}^{n} a_i \delta_{ij}=a_j,\quad 1 \le ...
Hosein Rahnama's user avatar
3 votes
0 answers
133 views

Check an Option without Evaluation

Consider the following: ...
Mark Messa's user avatar
17 votes
1 answer
324 views

When is the righthand side of a RuleDelayed evaluated?

The documentation on RuleDelayed states that lhs :> rhs represents a rule that transforms lhs to rhs, evaluating rhs only after the rule is used. Consider the ...
Fred Simons's user avatar
  • 10.2k
106 votes
5 answers
6k 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 ...
Alexey Popkov's user avatar