Skip to main content
Corrected explanation
Source Link
Leonid Shifrin
  • 115.8k
  • 16
  • 341
  • 435

This is the same issue as described here (and in references therein). I suggest to read that answer and the linked discussions for an explanation of why this happens.

The workaround can be also the same as mentioned there:

foo2[x_] := With[{rule = Rule}, Table[rule[(unk /. log[var_] -> var), x], {unk, unks}] ]   

So that now

foo2[5] (* {n -> 5} *) 

Basically, it fools RuleDelayed (the one that results from SetDelayed, in DownValues[foo2]), so that it does not recognise the inner rule as such, and so does not rename xvar onin one part of the r.h.s.inner rule during the rule application.

This is the same issue as described here (and in references therein). I suggest to read that answer and the linked discussions for an explanation of why this happens.

The workaround can be also the same as mentioned there:

foo2[x_] := With[{rule = Rule}, Table[rule[(unk /. log[var_] -> var), x], {unk, unks}] ]   foo2[5] (* {n -> 5} *) 

Basically, it fools RuleDelayed (the one that results from SetDelayed, in DownValues[foo2]), so that it does not rename x on the r.h.s. during the rule application.

This is the same issue as described here (and in references therein). I suggest to read that answer and the linked discussions for an explanation of why this happens.

The workaround can be also the same as mentioned there:

foo2[x_] := With[{rule = Rule}, Table[rule[(unk /. log[var_] -> var), x], {unk, unks}] ] 

So that now

foo2[5] (* {n -> 5} *) 

Basically, it fools RuleDelayed (the one that results from SetDelayed, in DownValues[foo2]), so that it does not recognise the inner rule as such, and so does not rename var in one part of the inner rule during the rule application.

Source Link
Leonid Shifrin
  • 115.8k
  • 16
  • 341
  • 435

This is the same issue as described here (and in references therein). I suggest to read that answer and the linked discussions for an explanation of why this happens.

The workaround can be also the same as mentioned there:

foo2[x_] := With[{rule = Rule}, Table[rule[(unk /. log[var_] -> var), x], {unk, unks}] ] foo2[5] (* {n -> 5} *) 

Basically, it fools RuleDelayed (the one that results from SetDelayed, in DownValues[foo2]), so that it does not rename x on the r.h.s. during the rule application.