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