柯里化就是把多变量函数转为单变量函数并顺次调用
var cache = []
var CurryAdd = function (n) {if(n == undefined) {return cache.reduce((p, n) => p + n, 0)
}
else {cache.push(n)
return CurryAdd
}
}
CurryAdd(1)(2)(3)(4)() // 10
柯里化就是把多变量函数转为单变量函数并顺次调用
var cache = []
var CurryAdd = function (n) {if(n == undefined) {return cache.reduce((p, n) => p + n, 0)
}
else {cache.push(n)
return CurryAdd
}
}
CurryAdd(1)(2)(3)(4)() // 10