Re: Deleting Selective DownValues
- To: mathgroup at smc.vnet.net
- Subject: [mg63998] Re: [mg63984] Deleting Selective DownValues
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Fri, 27 Jan 2006 05:13:09 -0500 (EST)
- References: <200601260843.DAA22208@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 26 Jan 2006, at 08:43, David Park wrote: > Dear MathGroup, > > Suppose I have established the following definitions for f, but not > necessarily in the given order. > > Clear[f] > f[x_, y_, z_] := x y z > f[a_, b_] := a b > f[x_] := x > DownValues[f] > {HoldPattern[f[x_, y_, z_]] :> x y z, HoldPattern[f[a_, b_]] :> a b, > HoldPattern[f[x_]] :> x} > > Now I would like to delete the f definition that has a given number > of arguments, say f[a_,b_] with 2 arguments. So I need a routine: > > deleteDownValue[label_Symbol,numberOfArgs_Integer?Positive]:= ??? > > which would reset DownValues[label] to eliminate any definition > with numberOfArgs arguments. > > I have trouble with doing the matches and evaluation sequences. Can > anyone help with this? Many thanks in advance. > > David Park > djmp at earthlink.net > http://home.earthlink.net/~djmp/ > How about something much simpler: In[1]:= Clear[f] f[x_, y_, z_] := x*y*z f[a_, b_] := a*b f[x_] := x DownValues[f] Out[5]= {HoldPattern[f[x_, y_, z_]] :> x*y*z, HoldPattern[f[a_, b_]] :> a*b, HoldPattern[f[x_]] :> x} In[6]:= f[x_, y_] =. In[7]:= DownValues[f] Out[7]= {HoldPattern[f[x_, y_, z_]] :> x*y*z, HoldPattern[f[x_]] :> x} ?? Andrzej Kozlowski
- References:
- Deleting Selective DownValues
- From: "David Park" <djmp@earthlink.net>
- Deleting Selective DownValues