[Issue 13940] std.algorithm.argMin

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jan 5 13:12:11 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13940

bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc

--- Comment #1 from bearophile_hugs at eml.cc ---
See Issue 4705 where I suggested to add to max/min an optional "key" argument
unary function.

So to find the min or max with a key of a sequence you use a reduce:

someRange.reduce!(max!abs)

It evaluates the key function only once for item. It's similar to the max/min
Python functions. And it's probably among my top additions to Phobos, beside a
pairwise (Issue 6788 ).

--


More information about the Digitalmars-d-bugs mailing list