January 2020
Intermediate to advanced
532 pages
13h 31m
English
One drawback of the preceding method is that we must define the original function as an anonymous function rather than a generic function. That seems to be a major constraint. The question is why doesn't it work with generic function?
Let's do a quick test by starting a new Julia REPL, defining the original fib function again, and wrapping it with the same memoize function:

The problem is that fib is already defined as a generic function, and it cannot be bound to a new anonymous function, which is what is being returned from the memoize function. To work around the issue, we may be tempted ...
Read now
Unlock full access