3 ms·
This is actually quite difficult to do automatically. A sibling comment lays this out quite nicely. Because memoization often can affect the asymptotic runtime
by dwohnitmok 7y ago
This is actually quite difficult to do automatically. A sibling comment lays this out quite nicely.
Because memoization often can affect the asymptotic runtime of algorithms (and of course space usage), this can lead to very confusing behavior for a user, if you determine at runtime similarly to a JIT compiler whether to memoize. Imagine an algorithm's asymptotic complexity jumping back and forth between exponential and linear over the course of a program running as the runtime analyzer memoizes and unmemoizes a function call.
Since you already have a lazy language, you can direct users to use lazy data structures to achieve memoization. http://jelv.is/blog/Lazy-Dynamic-Programming/ http://jelv.is/blog/Lazy-Dynamic-Programming/