Hello,
a workaround could be to delete just the entries of DownValues
which contain the symbol u.
To demonstrate I add to your example
Subscript[u, k_] := k; Subscript[u, 2]
2
another one of similar form:
Subscript[v, k_] := k; Subscript[v, 2]
2
Here are the values stored in the down values list of subscript:
DownValues[Subscript]
{HoldPattern[Subscript[v, k_]] :> k, HoldPattern[Subscript[u, k_]] :> k}
To delete definitions made just to u use something like
DownValues[Subscript] = Select[DownValues[Subscript], FreeQ[#, u,
\[Infinity]] &]
{HoldPattern[Subscript[v, k_]] :> k}
Now the definition for u_k is deleted
Subscript[u, 2]
Subscript[u, 2]
while the definition for v_k is still present
Subscript[v, 2]
2
To this end you could define something like:
myClear[x_Symbol] := Block[{},
DownValues[Subscript] = Select[DownValues[Subscript], FreeQ[#, x,
\[Infinity]] &]];
which works as expected:
myClear[v];Subscript[v,2]
Subscript[v,2]
Hope that helps,
Christoph
On 05/20/2012 08:34 AM, Peter Breitfeld wrote: