diff -r 000781318c36 -r b54b350dff5d src/maths.h --- a/src/maths.h Fri Jul 30 01:28:39 2021 +0300 +++ b/src/maths.h Fri Aug 27 00:55:32 2021 +0300 @@ -72,7 +72,32 @@ } constexpr double infinity = std::numeric_limits::infinity(); constexpr long double pi = M_PIl; - + // Returns the minimum value of a container + template + inline auto nmin(T&& values) + { + auto it = std::begin(values); + auto result_p = it; + for (++it; it != std::end(values); ++it) + { + if (*it < *result_p) + result_p = it; + } + return *result_p; + } + // Returns the maximum value of a container + template + inline auto nmax(T&& values) + { + auto it = std::begin(values); + auto result_p = it; + for (++it; it != std::end(values); ++it) + { + if (*it > *result_p) + result_p = it; + } + return *result_p; + } /* * Returns the empty sum. (recursion base) */