[Date Index]
[Thread Index]
[Author Index]
Re: Clearing function definitions by argument type?
*To*: mathgroup at smc.vnet.net
*Subject*: [mg57247] Re: Clearing function definitions by argument type?
*From*: David Bailey <dave at Remove_Thisdbailey.co.uk>
*Date*: Sun, 22 May 2005 00:14:11 -0400 (EDT)
*References*: <d6mn17$gkf$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
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
http://www.dbaileyconsultancy.co.uk
Prev by Date:
**Re: Bode Plots in Mathematica**
Next by Date:
**Re: Re: Re: Re: How to get an answer as a Root object?**
Previous by thread:
**Re: Clearing function definitions by argument type?**
Next by thread:
**Re: Re: Clearing function definitions by argument type?**
| |