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 <[email protected]>
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.
[...]
Andrei
What about ultimum? It means the last or the outermost.