MathGroup Archive 2001

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

Search the Archive

Re: Recursive Rules


In a message dated 2001/10/13 3:17:53 AM, mcoleman at bondspace.com writes:

>I know that a recurrent/recursive function can be written 
>
>f[t_] := f[t] = a + b*f[t-1].
>
>So that once an initial value is stipulated, e.g., f[0]=0, then the 
>function "remembers" past values and can correctly calculate f[] for 
>any t. 
>
>I was wondering if it was possible to do the same thing with a Rule?
>

Use ReplaceRepeated (//.)

fact[0] = 1;

fact[5] //. fact[n_] -> n*fact[n-1]

120

f[1] = c;

f[4] //. f[n_] -> a+b*f[n-1]

a + b*(a + b*(a + b*c))


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Plot-Function
  • Next by Date: style sheeting
  • Previous by thread: Recursive Rules
  • Next by thread: Re: Recursive Rules