Lambda算子5b：How of Y

其实是 这篇文章的意译。有些东西省了。添了点私货。就有了下面的帖子。

1: function fact(n){2:         if(n == 0){3:                 return 1;4:         }5: 6:         if(n > 0){7:                 return n * fact(n - 1);8:         }9: }

09: fact2 = function(himself, n){10:         return function(n){11:                 if(n < 2){12:                         return 1;13:                 }14: 15:                 return n * (something_expression_with_himself);16:         }17: }

19: fact3 = function(himself, n){20:         if( n < 2 ){21:                 return 1;22:         }23: 24:         return n * himself(himself, n-1);25: }

17: fact4 = function(himself){18:         return function(n){19:                 if( n < 2 ){20:                         return 1;21:                 }22: 23:                 return n * himself(himself)(n-1);24:         }25: }

37: fact5 = function(h){38:         return function(n){39:                 var f = function(q){40:                         return function(n){41:                                 if(n < 2){42:                                         return 1;43:                                 }44: 45:                                 return n * q(n-1);46:                         }47:                 }48: 49:                 return f(h(h))(n);50:         }51: }

37: fucntion f(q){38:         return function(n){39:                 if(n < 2){40:                         return 1;41:                 }42: 43:                 return n * q(n-1);44:         }45: }46:
47: function fact5(h){48:         return function(n){49:                 return f(h(h))(n);50:         }51: }

69: function Y(f){70:          g = function(h){71:                 return function(x){72:                         return f(h(h))(x);73:                 }74:          }75: 76:          return g(g);77: }

79: fact6 = Y(80:         function(h){81:                 return function(n){82:                         if(n < 2){83:                                 return 1;84:                         }85: 86:                         return n * h(n-1);87:                 }88:         }89: );

05-10 3618

10-09 823
02-10 4704
12-01 16万+
06-12 1万+
05-29 1万+
07-15 8万+
09-24 1万+
08-14 1万+
12-19 189
08-27 7497
08-04 1122
05-22 1万+
09-18 632
10-15 7万+
02-09 5576
06-11 74
12-01 2023
10-21 2652
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客