MathGroup Archive 2005

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

Search the Archive

Re: Re: Clearing function definitions by argument type?







On Sun, 22 May 2005 00:14:11 -0400 (EDT), David Bailey <dave at> wrote:

> Gareth Russell wrote:
>> Hi Group,
>> Is there a straightforward way to Clear only definitions that  take
>> certain kinds of arguments? For example, I might have
>> f[x_]:=x^2
>> f[0]=1
>> f[1]=1
>> f[2]=7
>> ...
>> and want to clear all f[number] definitions but not the DelayedSet
>> definition. (Note that the number of f[number] definitions will vary,
>> as will the numbers that each one takes as an argument.)
>> My goal is to clear 'memorized' definitions after an optimization run,
>> where the memorized definitions are generated by a
>> f[x_]:=f[x]=x^2
>> type of function, without clearing the function itself.
>> Gareth Russell
>> Columbia University
> You can see all the assignments in DownValues[g], and you could remove
> the parts of that list that you did not want and then execute
> DownValues[g]:=.....
> However, I think it might be easier to rearrange your problem a bit. If
> you 'remember' your answers in another function - g, then you can write
> f as
> f[x_] := If[NumberQ[g[x]], g[x], g[x] = x^2]
> Then you can just use Clear[g] when you want to start the next problem.
> David Bailey

DrBob at

  • Prev by Date: Re: MultipleListPlot and Log-List plots
  • Next by Date: Re: Re: Bode Plots in Mathematica
  • Previous by thread: Re: Clearing function definitions by argument type?
  • Next by thread: Bode Plots in Mathematica