Re: Deleting a DownValue, Evaluate[f@@argList]=. does not do it
- To: mathgroup at smc.vnet.net
- Subject: [mg20784] Re: [mg20744] Deleting a DownValue, Evaluate[f@@argList]=. does not do it
- From: "David Park" <djmp at earthlink.net>
- Date: Thu, 11 Nov 1999 00:22:53 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Adalbert, I think you need a little routine to do it. Attributes[clearf] = {HoldFirst}; clearf[f_[args__]] := Module[{g, expr}, expr = HoldPattern[x] /. x :> g[args] /. g -> f; Evaluate[expr] =. ] Clear[f] Evaluate[f @@ {1}] = 1; Evaluate[f @@ {1, 2}] = 2; Evaluate[f @@ {1, 2, 3}] = 5; ?? f Global`f f[1] = 1 f[1, 2] = 2 f[1, 2, 3] = 5 clearf[f[1, 2]] ??f Global`f f[1]=1 f[1,2,3]=5 David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ >Hi, MathGroup, > >f[1]=1; >f[2]=2; >?f > >yields > >"Global`f" >f[1] = 1 >f[2] = 2 > >now get rid of definition for 1 > >f[1]=.; >?f > >yields > >"Global`f" >f[2] = 2 > > >So far, it works as expected. I want to memorize results for combinations of arguments >like f[a,b,c]=results and so on. To do this, I write f@@argList. Now I demonstrate >this on lists with length 1, to make it simple. When making the assignment, it has to be >wrapped in Evaluate: > >Clear[f]; >Evaluate[f@@{1}]=1; >Evaluate[f@@{2}]=2; >?f > >yields > >"Global`f" >f[1] = 1 >f[2] = 2 > >as before. Now I want to get rid of the definition for 1 in the analogous way: > >Evaluate[f@@{1}]=. > >yields > >Unset::usraw: Cannot unset raw object ! >$Failed > >How to proceed without searching through DownValues[f] and deleting >the one meant - very awkward? > >kind regards > >Dipl.-Math. Adalbert Hanszen > >