RE: Prefix[f[x]], why is it not working
- To: mathgroup at smc.vnet.net
- Subject: [mg38919] RE: [mg38909] Prefix[f[x]], why is it not working
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 19 Jan 2003 00:33:06 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Ashraf, I think it is because Prefix is a formatting function that affects how the expression is displayed. But the prefix header is still there. Prefix[s[a_]] % // FullForm s@a_ Prefix[s[Pattern[a, Blank[]]]] So when you try to make an assignment with it, Mathematica objects because Prefix is protected. On the other hand... s@a_ % // FullForm s[a_] s[Pattern[a, Blank[]]] and you can make an assignment because s is not protected. I have to admit that this is a little tricky and confused me at first. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Ashraf El Ansary [mailto:Elansary at btopenworld.com] To: mathgroup at smc.vnet.net Hi all, Does anyone why f@a_=2 a gives a proper answer for f[1] and not in the case of Prefix[s[a_]]= 2 a eventhough that Prefix[s[a_]]= f@a_??? Thanks In[1]:= f@a_=2 a f[1] Out[1]= 2 a Out[2]= 2 In[3]:= Prefix[s[a_]] Prefix[s[a_]]=2 a s[1] Out[3]= s@a_ Set::write: Tag Prefix in s@a_ is Protected. Out[4]= 2 a Out[5]= s[1]