argmin_

version(none)
@safe pure
argmin_
(
alias fun
Range
)
(
in Range r
)
if (
isInputRange!Range &&
is(typeof(fun(r.front) < fun(r.front)) == bool)
)

Return Value

Type: auto

Element in r that minimizes fun. LaTeX: \underset{x}{\arg\min}

Examples

assert(argmin!(x => x*x)([1, 2, 3]) == 1);
assert(argmin!(x => x*x)([3, 2, 1]) == 1);

Meta