如何编写一个可以使用一个参数连续多次调用的函数?这是一个例子:
test_run()
X = [ 2.], Y = [ 0.75]
X = [ 2.], Y = [ 0.75]
X = [ 2.00000001], Y = [ 0.75000001]
X = [ 0.99999999], Y = [ 0.75000001]
X = [ 1.5], Y = [ 0.5]
X = [ 1.5], Y = [ 0.5]
X = [ 1.50000001], Y = [ 0.5]
Optimization terminated successfully. (Exit mode 0)
Current function value: 0.5
Iterations: 2
Function evaluations: 7
Gradient evaluations: 2
Minima found at:
X = [ 1.5], Y = 0.5
答案 0 :(得分:2)
返回另一个函数,当调用时,对第一个和第二个参数求和,如下所示:
function sum(a) {
return b => a + b
}
console.log(sum(1)(2))