i am using Math.net, among other methods i use integration, the integration function i use is defined as foloows:
public static double IntegrateComposite(
Func<double, double> f,
double intervalBegin,
double intervalEnd,
int numberOfPartitions)
yet, my call syntax is:
p = IntegrateComposite(
tau => MyFunction(r, tau, appCfg, Ta, Da) * ProbDensity(tau),
lowLim, hiLim, 32)
My function is better defined as Func<double, double, double, double, double, double>
and not the above Func<double, double>
, still everything works fine
Why?
This is your the function you pass in, the only input argument is tau.
tau => MyFunction(r, tau, appCfg, Ta, Da) * ProbDensity(tau)
The other varibales r, appCfg, Ta, Da
are 'closed over' by a closure
Func<double, double>
means
a function which takes 1 argument of type double in, and returns double
That's exactly what your arrow function does, no matter how many external variables are involved into calculation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With