MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Deleting Selective DownValues

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64014] Re: [mg63985] Deleting Selective DownValues
  • From: Hartmut.Wolf at t-systems.com
  • Date: Fri, 27 Jan 2006 05:13:31 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----Original Message-----
> From: David Park [mailto:djmp at earthlink.net] 
To: mathgroup at smc.vnet.net
> Subject: [mg64014] [mg63985] Deleting Selective DownValues
> 
> 
> 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/ 
> 

Dear David,

Perhaps you might like to consider


Off[Unset::"norep"];
Cases[DownValues[f], Unevaluated[lhs : f[_, _] :> (lhs =.)], {3}];

--
Hartmut


  • Prev by Date: Re: How to define a constant in mathematica like Pi
  • Next by Date: Re: Deleting Selective DownValues
  • Previous by thread: Re: Deleting Selective DownValues
  • Next by thread: Re: Deleting Selective DownValues