Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to do tail recursion in python

from tail_recurse import *

@tail_call
def fact(n):
    def tail_func(n, res):
        if n == 1:
            return res
        else:
            return tail_func(n - 1, n * res)

    return tail_func(n, 1)
Comment

PREVIOUS NEXT
Code Example
Python :: Returns a DataFrame representing the result of the given query 
Python :: cv2 remove black borders on images 
Python :: python init dict by list 
Python :: one line if statement python 
Python :: python sort() and sorted() 
Python :: class python __call__ 
Python :: python switch 
Python :: python text recognition 
Python :: pyqt popup yes no 
Python :: create a list of sequential numbers in python 
Python :: how to create a numpy array linspace in python 
Python :: python iterate over tuple of lists 
Python :: map in python 
Python :: python enable pyqt errors 
Python :: one function in numpy array 
Python :: standard streams with python3 
Python :: gui python 
Python :: format exponentials python 
Python :: unique list 
Python :: how to check if a key is present in python dictionary 
Python :: selenium session id python 
Python :: sum() python 
Python :: python grab results from cursor.execute 
Python :: python - subtracting dictionary values 
Python :: from sklearn.metrics import confusion_matrix pred = model.predict(X_test) pred = np.argmax(pred,axis = 1) y_true = np.argmax(y_test,axis = 1) 
Python :: how to block empty space python login 
Python :: python resample and interpolate 
Python :: python zip 
Python :: list length python 
Python :: flask blueprints 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =