Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Clearing function definitions by argument type?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57250] Re: Clearing function definitions by argument type?
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Sun, 22 May 2005 00:14:15 -0400 (EDT)
  • Organization: University of Washington
  • References: <d6mn17$gkf$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Gareth Russell" <gjr2008 at columbia.edu> wrote in message 
news:d6mn17$gkf$1 at smc.vnet.net...
> 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
>

One idea is to modify the DownValues of f directly:

DownValues[f] =
 DeleteCases[DownValues[f], RuleDelayed[a_, _] /; FreeQ[a, Pattern]]

Carl Woll 



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