On 9/15/11 12:14 PM, Jonathan M Davis wrote:
On Thursday, September 15, 2011 03:41 bearophile wrote:
It seems
(to me) more natural to give it a predicate to compare elements two at a
time. This is what is used in c++ std lib.

It's less natural. And D is not C++, there are more than just C++
programmers in D. And it leads to longer&  more complex code.

I think that that's up for debate. I would fully expect a min/max function to
be using a comparator function, which means using a binary predicate. Also,
given that everything else in std.algorithm which takes a predicate is taking
an actually predicate and not what should be compared, having max take
something like "a.length" would be extremely bizarre. I don't find
max!"a.length"(range) to be natural at all. Maybe it's more natural for
someone with little to no programming experience, but I really don't think
that your average programmer is going to find it more natural.

- Jonathan M Davis

I just realized argmax is exactly the name bearophile is looking for (http://en.wikipedia.org/wiki/Arg_max). I know, I'm awesome with names like that.

We should add argmax to phobos.


Andrei

Reply via email to