struct Point
{
double x, y;
}
import std.algorithm : min, max;
auto min_x = double.max;
auto max_x = -double.max;
auto min_y = double.max;
auto max_y = -double.max;
foreach (const ref p; points) // fold
{
min_x = min(min_x, p.x);
max_x = max(max_x, p.x);
min_y = min(min_y, p.y);
max_y = max(max_y, p.y);
}
Hello,
I am trying to find the min and max values from an array of points, I want to replace this with the std.algorithm fold, but I can't quite figure out the syntax for doing it?