Is there a golden standard optimal way of stacking several Func
in a row?
I my case I have some point transformations in a list of Func
.
List<Func<Point3D, Point3D>> combined = new List<Func<Point3D, Point3D>>();
Point3D translateVector = new (10,0,0);
Func<Point3D, Point3D> translate = (p) => p + translateVector;
combined.Add(translate);
Func<Point3D, Point3D> scale = (p) => p * 123;
combined.Add(translate);
So far so good. Now comes the ugly part: I want to nicely apply the functions to my points.
for (int p = 0; p < points.Count; p++)
{
foreach(var function in combined )
{
points[p] = function(points[p]);
}
}
This seems like a clunky way of achieving the combined Func.
Is there a better way?