MathGroup Archive 2002

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

Search the Archive

removing rules from function definitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33028] removing rules from function definitions
  • From: Erich Neuwirth <erich.neuwirth at univie.ac.at>
  • Date: Tue, 26 Feb 2002 04:35:19 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

let me explain my problem with a simplified example
i define
f[1] := f[1] = 1
f[n_] /; n > 1 := f[n] = f[n - 1]*2
after evaluating f[1]
i have

In[36]:=
FullForm[DownValues[f]]

Out[36]//FullForm=
List[RuleDelayed[HoldPattern[f[1]],1],RuleDelayed[HoldPattern[f[2]],2],
  RuleDelayed[HoldPattern[f[3]],4],RuleDelayed[HoldPattern[f[4]],8],
  RuleDelayed[HoldPattern[f[5]],16],RuleDelayed[HoldPattern[f[6]],32],
  RuleDelayed[HoldPattern[f[7]],64],RuleDelayed[HoldPattern[f[8]],128],
  RuleDelayed[HoldPattern[f[9]],256],
  RuleDelayed[HoldPattern[f[10]],Times[f[Plus[10,-1]],2]],
 
RuleDelayed[HoldPattern[Condition[f[Pattern[n,Blank[]]],Greater[n,1]]],
    Set[f[n],Times[f[Plus[n,-1]],2]]]]

no i want to remove all the rules which were added during the
evaluation.
Drop[DownValues[f],MyPattern]
essentially allows me to create a new rules list,
but i cannot get MyPattern right


MatchQ[#,RuleDelayed[HoldPattern[f[_Integer],_Integer]]

does not work because HoldPattern gets evaluated,
but doing it Verbatim does not work either
because then _Integer is not evakuated and therefore does not work any
more.


i really ned a pattern matching all rules

RuleDelayed[HoldPattern[f[_Integer]],_Integer]

which interprets _Integer nonverbatim, but everything else verbatim.
can anybody help me?


--
Erich Neuwirth, Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-38624 Fax: +43-1-4277-9386


  • Prev by Date: Re: need a function for sums of subsets
  • Next by Date: Re: sum problem with infinity
  • Previous by thread: RE: Hint on: Problems converting mathematica notebook to PDF with Acrobat Distiller
  • Next by thread: Re: removing rules from function definitions