DownValues question
- To: mathgroup at smc.vnet.net
- Subject: [mg70004] DownValues question
- From: dimmechan at yahoo.com
- Date: Sat, 30 Sep 2006 05:12:29 -0400 (EDT)
One more question. (I apologise for the number of questions).
The following rule is not allowed
x + y = z
Set::write : Tag Plus in x + y is Protected.
z
since Plus has the attribute Protected.
If you want to avoid the drastic way of Unprotect Plus and add the rule
you can use
x /: x + y = z
z
Suppose now the following
Clear[f]
f[x_, 2] := foo
f[2, x_] := foofoo
Then
DownValues[f]
{HoldPattern[f[x_, 2]] :> foo, HoldPattern[f[2, x_]] :> foofoo}
If you want, you can change the order that assigned down values are
stored by
DownValues[f] = Reverse[DownValues[f]]
{HoldPattern[f[2, x_]] :> foofoo, HoldPattern[f[x_, 2]] :> foo}
However
Attributes[DownValues]
{HoldAll, Protected}
Using Set we attach a value to the head of the left-hand side.
So, how we can (re)assign a new value to DownValues if its Head
has the attribute Protected?
Thanks in advance for any help.