Looking at a function in my code today, I wondered if it was possible to combine partial combination and optimisation:
let foo (X:float) y1 y2 dx =
y1 + (y2 - y1) * dx / X
Basically, just applying a ratio - so the first three parameters are generally the same within a given loop.
I thought maybe if I just did this:
let foo2 (X:float) y1 y2 dx =
let dy = (y2 - y1) / X
y1 + dy * dx
F# would get clever and optimise for me when I partially apply the first three parameters, but it debug mode it doesn't appear to be the case (though I'm not sure that I went about testing for it in the right way).
The question is, should this work? And if not is there a better way of doing it (apart from just writing another function with two parameters)?