MathGroup Archive 2006

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

Search the Archive

Re: Recursion inspection technique : HoldForm but release variables


flatmax schrieb:
> Hi,
> 
> If I define a recursion and hold its form to inspect it :
> Clear[test]
> test[j_Integer?Positive] :=
>                               test[j] = k[j] HoldForm[ test[j - 1] ]
> 
> then This is what happens :
> 
>    In[22]:= test[4]
> 
> Out[22]:= test[4 - 1] k[4]
> 
> But I would like it to be with the variable evaluated :
> 
> Out[22]:= test[3] k[4]
> 
> Whats the trick ???
> 
> thanks
> Matt
> 

Hi Matt,

  another possibility is to Hold just the function's name:

In[1]:=
Clear[test]
test[(j_Integer)?Positive] :=
   test[j] = k[j]*HoldForm[test][j - 1]
In[3]:=
test[4]
Out[3]=
k[4]*HoldForm[test][3] (* displays as k[4]*test[3] *)

hth,
   Peter


  • Prev by Date: Re: Beginner--How to simulate multiple returns for a function?
  • Next by Date: Re: Checking the sign of a Mathematical expression
  • Previous by thread: Re: Recursion inspection technique : HoldForm but release variables
  • Next by thread: Color Matching Functions to model human vision?