blob: ed03f66a73923639045f88c99c94f775d4a44265 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
function testClosureCreationAndInvocation() {
var a = 'foobar';
function makeaddv(vvvv) {
var z = -4 * vvvv;
var y = -3 * vvvv;
var x = -2 * vvvv;
var w = -1 * vvvv;
var v = 0 * vvvv;
var u = 1 * vvvv;
var t = 2 * vvvv;
var s = 3 * vvvv;
var r = 4 * vvvv;
var q = 5 * vvvv;
var p = 6 * vvvv;
var o = 7 * vvvv;
var n = 8 * vvvv;
var m = 9 * vvvv;
var l = 10 * vvvv;
var k = 11 * vvvv;
var j = 12 * vvvv;
var i = 13 * vvvv;
var h = 14 * vvvv;
var g = 15 * vvvv;
var f = 16 * vvvv;
var e = 17 * vvvv;
var d = 18 * vvvv;
var c = 19 * vvvv;
var b = 20 * vvvv;
var a = 21 * vvvv;
return function (x) {
switch (x) {
case 0: return a; case 1: return b;
case 2: return c; case 3: return d;
case 4: return e; case 5: return f;
case 6: return g; case 7: return h;
case 8: return i; case 9: return j;
case 10: return k; case 11: return l;
case 12: return m; case 13: return n;
case 14: return o; case 15: return p;
case 16: return q; case 17: return r;
case 18: return s; case 19: return t;
case 20: return u; case 21: return v;
case 22: return w; case 23: return x;
case 24: return y; case 25: return z;
}
};
}
var a = Array();
for (var i = 0; i < 26; ++i) {
a.push(makeaddv(Math.random()));
}
return a;
}
var a = testClosureCreationAndInvocation();
for (var i = 0; i < 26; ++i) {
print(a[i](i));
}
|