MathGroup Archive 2002

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

Search the Archive

Re: removing rules from function definitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33036] Re: removing rules from function definitions
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 27 Feb 2002 00:47:51 -0500 (EST)
  • Organization: Universitaet Leipzig
  • References: <a5fm7i$e1k$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

we have had the problem three weeks ago and


DownValues[f] = 
  DownValues[f] /. 
    (Verbatim[HoldPattern][f[i_Integer]] :> _) /; i > 1 :> 
      Sequence[]

will do that.

Regards
  Jens

Erich Neuwirth wrote:
> 
> 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: need a function for sums of subsets
  • Next by Date: loop problem?
  • Previous by thread: Re: removing rules from function definitions
  • Next by thread: How to read in the output of another nb file?