Linked Questions

6
votes
0answers
64 views

Nested rules and automatic renaming of variables [duplicate]

I understand why $ happens here: ClearAll[foo] foo[a_] := (x_ :> a x) foo[1] ...
47
votes
5answers
2k views

Enforcing correct variable bindings and avoiding renamings for conflicting variables in nested scoping constructs

Using global variables the following turns an "expression" into a Function: expr = 2 x; Function[x, Evaluate[expr]] Of course ...
19
votes
2answers
2k views

Scraping High-Res images from the MoMA and the Van Gogh Museum websites

Many art websites allow the user to zoom into an image to see it at high resolution by using image tiles. It is great on the website, but presents problems if one wishes to compile a complete high ...
30
votes
1answer
856 views

Is the renaming mechanism of `With` flawed?

I'm confused about the renaming mechanism of With: ...
20
votes
2answers
1k views

I define a variable as local to a module BUT then the module uses its global value! Why?

I have a question about modules and local variables. Here's my example: h = 5; Module[{a, h}, a[h_]= h^2; a[4]] (*Out[2] = 25*) I expected the module to ...
16
votes
1answer
443 views

StringReplace, ReplaceAll and Rule interact in a bizarre way

I have the following pair of things: ClearAll[foo, labeledFoo]; labeledFoo = {"FooBarBazQuux", foo}; This works like you'd expect: ...
6
votes
0answers
345 views

Exhaustive examples of variable replacement due to nested scoping constructs

Consider the following examples, where I have replaced dollar signs in the output by a D. ...
4
votes
1answer
104 views

Scoping problem? [duplicate]

Why (f[1, 0] /. {x : 0 | 1 :> 1 - x}) -> 0 returns (expectedly) f[0, 1] -> 0, while ...
5
votes
1answer
71 views

Inconsistent application of replacement rule

I want to use a replacement rule to change log[var] into var inside a function. A minimal example follows. In one case it ...
4
votes
0answers
131 views

Why does `… := With[{var = …}, …]` create `var$`?

EDIT This issue is specifically different from the "duplicate" question. The creation of variables in the active context during parsing is of no surprise and is the expected behavior. What I'm ...
3
votes
1answer
70 views

ReplaceAll Wierdness

I've come across some weirdness in ReplaceAll. Replacement works fine outside of a module, but inside the module some replacements don't occur where one might expect them to. ...
2
votes
0answers
36 views

Strange Replace problem within RuleDelayed within function [duplicate]

I've run into a strange anomaly with Replace when it is performed inside the first argument of RuleDelayed within a function ...