var show = console.log;
function compose(f, g)
{
return x => f(g(x));
}
var g = x => "value is " + x;
var f = show;
/**
* c1的值为 x => f(g(x))
* 即:x => show((x => "value is " + x)(x))
* 是下面函数的缩写
* x => (x => show(x)) ((x => "value is " + x)(x))
*/
var c1 = compose(f, g);
show(c1);
c1(5);
( x => show((x => "value is " + x)(x)) )(5);
( x => (x => show(x)) ((x => "value is " + x)(x)) ) (5);
compose函数
最新推荐文章于 2024-07-08 16:22:29 发布