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

From: Paulo Moura <pmoura_at_di.ubi.pt>
Date: Thu, 16 Nov 2006 18:37:58 +0000

On 2006/11/16, at 18:21, Joachim Schimpf wrote:

> 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_?

Yes.

> 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,

Agree.

> 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).

See the Jan reply he sent this morning. In the current version
(5.6.23) the result also depends on the argument order, which I think
is buggy behavior.

Cheers,

Paulo

-----------------------------------------------------------------
Paulo Jorge Lopes de Moura
Dep. of Computer Science, University of Beira Interior
6201-001 Covilhã, Portugal

Office 4.3 Ext. 3257
Phone: +351 275319891 Fax: +351 275319899
Email: <mailto:pmoura_at_di.ubi.pt>

Home page: <http://www.di.ubi.pt/~pmoura>
Research: <http://logtalk.org/>
-----------------------------------------------------------------

_______________________________________________
prolog-standard mailing list
prolog-standard_at_neve.di.ubi.pt
http://neve.di.ubi.pt/mailman/listinfo/prolog-standard
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