www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13940] New: std.algorithm.argMin


          Issue ID: 13940
           Summary: std.algorithm.argMin
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: peter.alexander.au gmail.com

I've often needed this function (and added it really early on to my utilities

auto argMin(alias f, alias pred = "a < b", InputRange)(InputRange arg)
    return arg.minPos!((a, b) => binaryFun!pred(f(a), f(b))).front;

Ideally the implementation would cache the evaluation of f(x) so that it is
only evaluated once per element.


Jan 05 2015