8 lines
No EOL
186 B
Python
8 lines
No EOL
186 B
Python
def memoize(f):
|
|
cache = {}
|
|
def memoized_function(*args):
|
|
if args not in cache:
|
|
cache[args] = f(*args)
|
|
return cache[args]
|
|
|
|
return memoized_function |