Hello.
Suppose I have a family of functions
f_0(x) = 0*x
f_1(x) = 1*x
....
f_n(x) = n*x
taking float and returning float (naturally, the actual functions would
be much more complex).
I'd like to pass the pointers to these functions one by one (in a loop)
to another function accepting an argument of type float (*)(float).
The problem is that the amount of these functions (or the n parameter)
will be determined at the runtime.
Is there a way to generate somehow such a family in the form of an array
float (*[])(float) ?
Or, having a function
float func(int i, float x) { return i*x; }
is it possible to "cast" it somehow to obtain an array indexed by i such
that (symbolically)
a[i](x) = func(i, x)
for all n and x ?
Thanks.
Suppose I have a family of functions
f_0(x) = 0*x
f_1(x) = 1*x
....
f_n(x) = n*x
taking float and returning float (naturally, the actual functions would
be much more complex).
I'd like to pass the pointers to these functions one by one (in a loop)
to another function accepting an argument of type float (*)(float).
The problem is that the amount of these functions (or the n parameter)
will be determined at the runtime.
Is there a way to generate somehow such a family in the form of an array
float (*[])(float) ?
Or, having a function
float func(int i, float x) { return i*x; }
is it possible to "cast" it somehow to obtain an array indexed by i such
that (symbolically)
a[i](x) = func(i, x)
for all n and x ?
Thanks.
Comment