Disclaimer: I have almost no mathematics notions, so this question could be very basic for some of you.
I'm searching for the name of a concept which consists in combining functions together (say, functions with the same input and output types and number of parameters) to make them simpler.
Suppose I have these 3 methods with the same signature:
addOne(param: number): number {
return param + 1;
}
addTwo(param: number): number {
return param + 2;
}
multiplyByThree(param: number): number {
return param * 3;
}
Now I know that I'll always use these functions in the same order and same param.
Ex: I will process a sound or an image.
I want to avoid uselessly applying coefficient or offsets that could be computed together (optimization/regression).
Let's say I have this imaginary library with a method called computeOptimizedFunction
that applies this concept to my functions. It takes any number of functions with the same signature as input.
var optimized = computeOptimizedFunction(addOne, addTwo, multiplyByThree);
Actually equals to:
var optimized = (param: number) => 3 * (param + 3);
Anyone here has an idea of how this concept or pattern is called, if it exists?
Aucun commentaire:
Enregistrer un commentaire