I am trying to examine how the solution to an optimization problem changes as some parameters are changed in the objective. As a preliminary step, I am just trying to get comfortable modifying parameters in a function.
Here’s what I tried so far. It seems to work, but I think it may get awkward if there are many parameters or if embedded in an otherwise complex problem. Is there a better approach to this sort of thing (sorry I know that’s a bit vague)?
function f(x,y)
return x+y
end
function g(y)
function h(x)
return f(x,y)
end
return h
end
As desired, g(2)(7)
produced 9.
15 posts - 6 participants