Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Higher-order functions and operations on callable objects in python

@cache
def factorial(n):
    return n * factorial(n-1) if n else 1

>>> factorial(10)      # no previously cached result, makes 11 recursive calls
3628800
>>> factorial(5)       # just looks up cached value result
120
>>> factorial(12)      # makes two new recursive calls, the other 10 are cached
479001600
Comment

PREVIOUS NEXT
Code Example
Python :: download python for windows 7 32 bits 
Python :: how to sum 2 no.s in python 
Python :: /usr/local/lib/python3.7/dist-packages/pytube/captions.py in xml_caption_to_srt(self, xml_captions) 
Python :: pandas df where 
Python :: quicksort python 
Python :: how to print a character n times in python 
Python :: tokens in python 
Python :: python open application windows 
Python :: pandas merge validate 
Python :: inverting a dictionary 
Python :: yahoo finance python chart 
Python :: python hide terminal 
Python :: if else condition python 
Python :: python destructor 
Python :: python update function 
Python :: typing python 
Python :: Adding new column to existing DataFrame in Pandas 
Python :: python create empty dictionary with keys 
Python :: how to extract digits from a string in python 
Python :: optional arguments python 
Python :: Python list tutorial for beginners 
Python :: hide console in python build 
Python :: run python from c# 
Python :: set empty dictionary key python 
Python :: avoid self python by making class functions static 
Python :: python x = x + 1 
Python :: how to check if user pressed enter in python 
Python :: how to if in pythob 
Python :: pynput keyboard backspace 
Python :: infinite for loop in python 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =