Linked Questions

6 votes
0 answers
67 views

Nested rules and automatic renaming of variables [duplicate]

I understand why $ happens here: ClearAll[foo] foo[a_] := (x_ :> a x) foo[1] ...
Kuba's user avatar
  • 137k
50 votes
5 answers
3k 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 ...
einbandi's user avatar
  • 4,024
19 votes
2 answers
3k 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 ...
martin's user avatar
  • 8,768
32 votes
1 answer
956 views

Is the renaming mechanism of `With` flawed?

I'm confused about the renaming mechanism of With: ...
luyuwuli's user avatar
  • 2,814
22 votes
2 answers
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 ...
pan_e_gaban's user avatar
16 votes
1 answer
476 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: ...
Pillsy's user avatar
  • 18.5k
8 votes
1 answer
456 views

Rule rewriting behavior

This is kind of meta-programming attempt. Below are two snippets: Snippet 1: ...
Pavel Perikov's user avatar
4 votes
1 answer
151 views

Scoping problem? [duplicate]

Why (f[1, 0] /. {x : 0 | 1 :> 1 - x}) -> 0 returns (expectedly) f[0, 1] -> 0, while ...
Roma Lee's user avatar
  • 731
6 votes
0 answers
367 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. ...
Jacob Akkerboom's user avatar
5 votes
1 answer
78 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 ...
Chris K's user avatar
  • 20.3k
4 votes
0 answers
146 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 ...
LLlAMnYP's user avatar
  • 11.5k
3 votes
1 answer
90 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. ...
SkyCat's user avatar
  • 91
2 votes
0 answers
41 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 ...
Sean's user avatar
  • 645