Scoped variables
- To: mathgroup at smc.vnet.net
- Subject: [mg13898] Scoped variables
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Sun, 6 Sep 1998 02:55:35 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Consider the lines below. You get nothing very interesting at Out[1].
In[n]:=
Clear[a];
x=2;
{a_->x^2, x_->x^2, x_}//InputForm
Out[1]=
{a_ -> 4, x_ -> 4, x_}
It works a little different if you do the same thing inside With (see
below).
In[2]:=
With[{x=7},{a_->x^2, x_->x^2, x_}]//InputForm
Out[2]=
{a$_ -> 49, x_ -> 4, Pattern[7, _]}
I understand there were extensive discussions on this sort of thing in
this group in recent years. However, I can't find anything, mostly
because I haven't figured out how to use the MathGroup search engine.
Anyway I figured some members would still be interested.
Ted Ersek