0

I have this weird behavior of patterns inside the Module construct. Note that we have

In: Module[{}, a_->x]
Out: a_ -> x

While if x is scoped, then some garbage also appears in a

In: Module[{x}, a_->x]
Out: a$_ -> x$16509

Even more, it doesn't help if x has a value,

In: Module[{x}, x=4; a_->x]
Out: a$_ -> 4

Is there any explanation for this behavior/can it be avoided in some straightforward way? Note that this does not happen in Block.

The reason this is problematic for me is because I receive a global expression with variable a, and I want it to appear in the right hand side of the pattern, i.e.

In: expr=a^2; Module[{x}, x=4; stuff[a_]->expr * x]
Out: stuff[a$_] -> 4 a^2

P.S. Mathematica 11.2.0.0

0 Answers0