forked from solvery/lang-features
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda.1.js
More file actions
76 lines (59 loc) · 809 Bytes
/
Copy pathlambda.1.js
File metadata and controls
76 lines (59 loc) · 809 Bytes
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// http//blog.csdn.net/g9yuayon/article/details/1271319
alert=console.log
function fact(n){
if(n == 0){
return 1;
}
if(n > 0){
return n * fact(n - 1);
}
}
fact3 = function(himself, n){
if( n < 2 ){
return 1;
}
return n * himself(himself, n-1);
}
r=fact3(fact3, 3)
alert(r)
//
fact4 = function(himself){
return function(n){
if( n < 2 ){
return 1;
}
return n * himself(himself)(n-1);
}
}
function f(q){
return function(n){
if(n < 2){
return 1;
}
return n * q(n-1);
}
}
function fact5(h){
return function(n){
return f(h(h))(n);
}
}
function Y(f){
g = function(h){
return function(x){
return f(h(h))(x);
}
}
return g(g);
}
//
fact6 = Y(
function(h){
return function(n){
if(n < 2){
return 1;
}
return n * h(n-1);
}
}
);