Looking at the function in my code today, I wondered if it is possible to combine partial combination and optimization:
let foo (X:float) y1 y2 dx =
y1 + (y2 - y1) * dx / X
Basically, just applying the relation - therefore, the first three parameters in one cycle are usually the same.
I thought maybe if I just did this:
let foo2 (X:float) y1 y2 dx =
let dy = (y2 - y1) / X
y1 + dy * dx
F # will become smarter and optimized for me when I partially apply the first three parameters, but in this debugging mode this is not so (although I'm not sure that I started testing it in the correct way).
The question is, should this work? And if not, what is the best way to do this (other than just writing another function with two parameters)?
source
share