I am trying to create a function and return it from within another function, in the following way:
std::function<double(double)> to_equation(std::vector<double> coefficients)
{
double f(double t)
{
auto total = 0.0;
for (int i = 0; i < coefficients.length(); i++)
{
auto c = coefficients[i];
total += c * t ** i;
}
return total
};
return f;
}
the code does however not work. What did I do wrong?