Which inside Module causes problems with ReplaceAll
- To: mathgroup at smc.vnet.net
- Subject: [mg111375] Which inside Module causes problems with ReplaceAll
- From: "P. Fonseca" <public at fonseca.info>
- Date: Thu, 29 Jul 2010 06:44:24 -0400 (EDT)
Hi,
Version 7.0.1
This works:
In[7]:= test[x_]:=Module[{u},
u[t_]:=t^2;
u[x]]
In[8]:= test[t]/.t->3
Out[8]= 9
This doesn't:
In[9]:= test[x_]:=Module[{u},
Which[
x==0,0,
True,
u[t_]:=t^2;
u[x]
]
]
In[10]:= test[t]/.t->3
During evaluation of In[10]:= Pattern::patvar: First element in
pattern Pattern[3,_] is not a valid pattern name. >>
Out[10]= u$670[3]
What's going on?
Regards,
P. Fonseca