题目来源:
leetcode题目,网址:2629. 复合函数 - 力扣(LeetCode)
解题思路:
倒序遍历计算。
解题代码:
/*** @param {Function[]} functions* @return {Function}*/
var compose = function(functions) {return function(x) {for(let i=functions.length-1;i>=0;i--){x=functions[i](x);}return x;}
};/*** const fn = compose([x => x + 1, x => 2 * x])* fn(4) // 9*/
总结:
无官方题解。
这是函数数组?