Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Hi, actually, function 1 is called when python interpret the line that contain @function1. So it call it like this: function1(function2). This is redefining the function2 to what function1 returns.
If function1 return function2, later calls to function2 will indeed execute the code of function 2.
In the case of this solution, as memoized function is returning the wrapped function, later calls to fibonacci actually will call wrapped function (that has inside it the original fibonacci function).
So, when the interpreter reads the line "@memoized", it calls the memoized function (like this memoized(fibonnacci) ). Then it creates the empty dictionary and return the wrapper function. This way the dictionary is not redefined to empty at every call to fibonacci function.
The dictionary is still saved at the memory and the wrapper function has a reference to it.
Later call to fibonacci function will indeed call the wrapper function because the memoized functoin redefined it to wrapper function.
I still don't understand decorators in Python. Help me pls :(
This comment is hidden because it contains spoiler information about the solution
I like the naming convention memoized :D I used multitabres. And I don't know why lmao
actually, best practice is to use the spoiler flags... :p
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution