I am trying to implement a recursive function in python, let's call such function F, the input of such function is a list, lets call it a. The logic of the realization of F should be as following,
def F(a):
if this is first time I run this function (in other words if this is not the first time I run this function, leave a as it is):
a.reverse()
then do something recursively calling F
I want to ask that what is the simplest way of achieving such goal. Does python actually support such logic?
Fand do what you need to first or something likeF(a, first_time=False)and call it viaF(a, True)first_timein every recursive call. Wrappers are a good solution to one-time setup issues or data cleaning such as bounds checks.def Fx()that callsFafter doing whatever presetup you need