August 2016
Intermediate to advanced
635 pages
14h 5m
English
Not to be confused with memorization, memoization is a specific term for retaining a number of previously calculated values from a function.
As we saw earlier, side-effect-free functions can be called multiple times without causing problems. The corollary to this is that a function can also be called fewer times than needed. Consider an expensive function which does some complex or, at least, time-consuming math. We know that the result of the function is entirely predicated on the inputs to the function. So the same inputs will always produce the same outputs. Why, then, would we need to call the function multiple times? If we saved the output of the function, we could retrieve that instead of redoing the time-consuming math.
Trading ...