I have a problem with proper design of partial function application with changing bound variables.
Imagine I have some balancing equation
f(x_1,...,x_n)=0
Then I put there all the variables except for x_k (k changes!), getting the function
g(x_k)=f(x_1=X_1,...,x_k,...,x_n=X_n)
Then I put it in some solver and get the solution for x_k. Just a few lines of code for illustration:
Func<double,double,double> f;
Func<double,double> g;
f = (x,y) => x - y;
g = (z) => f(10,z); // hier is the binding of the 1-st parameter hard-coded,
//but must be some way to choose which parameter to bind
double solution = solve(g);
In some way I need to pass an array of length n-1, the number k to let free and build a new function g on the fly. How would you proceed?
p.s. if possible, n should be also variable, however, to my understanding it would be a big leap in code/design complexity. If you have a strong opinion on this point, please validate my understanding.