Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Recursion with foxpro
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01086981
Message ID:
01086994
Vues:
27
Recursion in VFP only allows 128 levels. (I understand that this might have been changed in VFP9)
I find it odd that you caught the stack exception when calling your function aa(75), because it should only go 75 levels.
What version of VFP are you using?

Einar

>Hi Peter,
>
>I was looking for an efficient way of doing this. Because if I'm doing a very simple recursion in foxpro I get an error message : insufficient stack space.
>
>Just doing the following, which represents an annuity:
>
>? aa(75)
>
>FUNCTION aa(n)
>
>IF n = 0 THEN
>	RETURN 0
>ENDIF
>
>RETURN 1 + 1/(1+0.04)*aa(n-1)
>ENDFUNC
>
>Maybe recursion is not the way to do these things in foxpro? In c# I can do it w/o any problem.
>
>
>>>Hi all,
>>>
>>>Is it possible to do recursion in foxpro? If so how would I set the following
>>>equations with recursion functions:
>>>
>>>aa(x,n) = 0.5 + 1/1.03*Px[state,state]*aa(x+1,n-1)
>>>+ 1/1.03*Px[state,state]*ia(x+1,n-1,1)
>>>
>>>ia(x,n,inv) = 0.5 + 1/1.03*Px[state,state]*aa(x+1,n-1)
>>>+ 1/1.03*Px[state,state]*ia(x+1,n-1,inv+1)
>>>
>>>where aa(x,0) = 0 and ia(x,0,inv) = 0 and ia(x,n,inv) = 0 for inv > 6 and Px is a given matrix.
>>
>>Sure, you can call a function from within that function. How that must be done with the above equation is your endeavour. :)
Semper ubi sub ubi.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform