October 2006
Intermediate to advanced
888 pages
16h 55m
English
Suppose you have a computationally expensive mathematical function that will be called repeatedly in the course of execution. If speed is critical and you can afford to sacrifice a little memory, it may be effective to store the function results in a table and look them up. This makes the implicit assumption that the function will likely be called more than once with the same parameters; we are simply avoiding “throwing away” an expensive calculation only to redo it later on. This technique is sometimes called memoizing, hence the name of the memoize library.
This is not part of the standard library, so you’ll have to install it.
The following example defines a complex function called zeta. (This solves a ...
Read now
Unlock full access