Re: [prolog-standard] Re: log10/1, log/2, min/2, and max/2

From: Joachim Schimpf <>
Date: Thu, 16 Nov 2006 18:21:05 +0000

Paulo Moura wrote:
> On 2006/11/16, at 05:17, Richard A. O'Keefe wrote:
>> min/2 and max/2
>> These functions do not COMBINE their arguments; they merely SELECT
>> one of them.
>> ...
> This seems to be the consensus between the people that have already
> provided feedback on these functions. The implementations that I tried
> also implement these functions as a select operation.

I suppose by "select" you mean that the result must be _identical_
to one of the inputs, rather than only _numerically_equal_?

Why is this desirable, when it leads to the problems indicated?
After all, this is an arithmetic function, so there is no reason
why it should not use the same floating-point contagion rule
like all other symmetric binary operations, i.e. if one of the
inputs is float, the result is float:

?- Min is min(2, 3.0).
Min = 2.0
Yes (0.00s cpu)

Then you have no problem with the equality case:

?- Min is min(2, 2.0), Max is max(2, 2.0).
Min = 2.0
Max = 2.0
Yes (0.00s cpu)
?- Min is min(2.0, 2), Max is max(2.0, 2).
Min = 2.0
Max = 2.0
Yes (0.00s cpu)

On the other hand, if you want select semantics, you have to decide
what to return if the arguments are numerically equal. I don't
see any reason why standard term order should play any role here,
or why the arguments order should be relevant (as seems to be the
case in an old SWI 5.6.9 I have here).

-- Joachim
prolog-standard mailing list
Received on Mon Jul 14 2008 - 13:01:01 EST

This archive was generated by hypermail 2.2.0 : Wed Sep 08 2010 - 23:28:17 EST