On 09/17/2011 03:55 PM, Mafi wrote:
Am 16.09.2011 23:38, schrieb Andrei Alexandrescu:
On 9/16/11 3:54 PM, Timon Gehr wrote:
On 09/16/2011 10:35 PM, Simen Kjaeraas wrote:
On Fri, 16 Sep 2011 22:16:59 +0200, Timon Gehr <timon.g...@gmx.ch>
wrote:
I suggest:
* Introduce the algorithm "extremum" with a required predicate.
What would that do? The range has more than one extremum if it is
non-constant.
extremum!"a<b"([1,2,3,1,2,3]) would be equal to [1,1].
(BTW I thought of just returning the first found, so only 1.)
That is not extremum. It is min.
Indeed extremum is not as good a name because it means an extreme value
of a unary function over an interval. Extending this to relations is a
bit forced.
The example shows min, but the difficulty in finding a good name is that
such a name would be meaningful in both of these cases:
xyz!"a<b"([1,2,3,1,2,3]) is 1
xyz!"a>b"([1,2,3,1,2,3]) is 3
Question is what's a good name for xyz. It returns the element X of the
range such that pred(E, X) is false for all E in the range. Then we'd
defined xyzCount and xyzPos and call it a day.
[...]
That is the definition of a minimum. pred is the order relation and the
range gives the set. Ergo xyz=min. But that is were we are.
Andrei
What about ultimum? It means the last or the outermost.
As long as the function computes a least element, any names other than
leastElem* or min* are just confusing. 'ultimum' is not specific enough.
"Does it compute a least element or a greatest element?" The approach of
having a name that includes both max and min cannot work in a
satisfiable way for that reason.