Method Function.memoize
Memoize (cache) the output of a function.
-
Syntax
Mixed Function.memoize(Mixed a0 ... an )
Will cache the output of a function call so that later calls to the same function using the same arguments are retrieved without computation.
Note that this method is somewhat experimental. If you find any errors please report them. -
Parameters
Mixed a0 ... an
- Return value Whatever the original function is returning.
-
Examples
- To cache the value for later retrieval of the function f
// Define function f var f = function() { // Do whatever... }; // Cache the result of computing f // with arguments 2 and 'hello world' f.memoize(2, 'hello world');
- Resources The Wikipedia entry on memoization.
-
Download
Source
Unless otherwise noted all code in the JSLab Standard Library is licensed as GPLv3. See http://www.gnu.org/licenses/gpl.html for the entire license.
