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.
I agree with your point that it's the "minimum according to the order
established by the predicate" but the fact of the matter is, "min" with
an arbitrary predicate is bound to confuse people. I also thought of
"bottom" from lattice theory, but that's also rather odd. So far my best
candidates are "bound" and "limit".
Andrei