time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (1101B)


      1 
      2 {{alias}}( fcn[, hashFunction] )
      3     Returns a memoized function.
      4 
      5     The function does not set the `length` property of the returned function.
      6     Accordingly, the returned function `length` is always zero.
      7 
      8     The evaluation context is always `null`.
      9 
     10     The function serializes provided arguments as a string and stores results
     11     using the string as an identifier. To use a custom hash function, provide a
     12     hash function argument.
     13 
     14     Parameters
     15     ----------
     16     fcn: Function
     17         Function to memoize.
     18 
     19     hashFunction: Function (optional)
     20         Function to map a set of arguments to a single value identifying that
     21         set.
     22 
     23     Returns
     24     -------
     25     out: Function
     26         Memoized function.
     27 
     28     Examples
     29     --------
     30     > function factorial( n ) {
     31     ...     var prod;
     32     ...     var i;
     33     ...     prod = 1;
     34     ...     for ( i = n; i > 1; i-- ) {
     35     ...         prod *= i;
     36     ...     }
     37     ...     return prod;
     38     ... };
     39     > var memoized = {{alias}}( factorial );
     40     > var v = memoized( 5 )
     41     120
     42     > v = memoized( 5 )
     43     120
     44 
     45     See Also
     46     --------
     47