Deleting Selective DownValues
- To: mathgroup at smc.vnet.net
- Subject: [mg63985] Deleting Selective DownValues
- From: "David Park" <djmp at earthlink.net>
- Date: Thu, 26 Jan 2006 03:43:12 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
I think I found the solution for deleting definitions with a given number of arguments. The trick was to change the function name to stop evaluation.
deleteDownValue[label_Symbol, numberOfArgs_Integer?Positive] :=
Module[{g},
DownValues[f] =
Select[DownValues[f],
Length[First[#] /. label -> g /. HoldPattern -> Identity] !=
numberOfArgs &];]
Clear[f]
f[x_, y_, z_] := x y z
f[a_, b_] := a b
f[x_] := x
DownValues[f]
deleteDownValue[f, 2]
DownValues[f]
{HoldPattern[f[x_, y_, z_]] :> x y z, HoldPattern[f[a_, b_]] :> a b,
HoldPattern[f[x_]] :> x}
{HoldPattern[f[x_, y_, z_]] :> x y z, HoldPattern[f[x_]] :> x}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
- Follow-Ups:
- Re: Deleting Selective DownValues
- From: "Carl K. Woll" <carlw@wolfram.com>
- Re: Deleting Selective DownValues