[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 17:45:40 +0000

On 2006/11/16, at 05:17, Richard A. O'Keefe wrote:

> log10/1
>
> Is log10 a popular evaluable function in existing Prologs?
> [SWI has it, my oldish copy of SICStus doesn't; QP didn't.]
> If so, it had better be standardised. However, I for one
> seldom need it. What I *do* need fairly often is log to the
> base 2. I note that both log10() and log2() are in the ISO C99
> standard.
>
> What I think would be best would be
>
> log(B, V)
> ...

I myself prefer a log/2 than the log10/1 in the current draft. If
there are no objections, I'm going to replace log10/1 by log/2 in the
next draft revision.

> 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. There are
however differences between implementations when the functions are
evaluated with an integer and a float representing the "same number".
For example:

pmmbp:~ pmoura$ sicstus

This version expires on 20061130
SICStus 4.0.0beta2 (powerpc-darwin-8.6.0): Fri Jun 30 14:39:35 CEST 2006
Licensed to di.ubi.pt
| ?- X is max(2.0, 2).
X = 2.0 ?
yes
| ?- X is max(2, 2.0).
X = 2.0 ?
yes
| ?- 2 @< 2.0.
no
| ?- 2 @> 2.0.
yes

pmmbp:~ pmoura$ yap
YAP version Yap-5.1.2
    ?- X is max(2.0, 2).
X = 2 ?
yes
    ?- X is max(2, 2.0).
X = 2 ?
yes
    ?- 2 @< 2.0.
no
    ?- 2 @> 2.0.
yes
    ?-

pmmbp:~ pmoura$ swipl
Welcome to SWI-Prolog (Multi-threaded, Version 5.6.23)
Copyright (c) 1990-2006 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- X is max(2.0, 2).

X = 2.0

Yes
?- X is max(2, 2.0).

X = 2

Yes
?- 2 @< 2.0.

No
?- 2 @> 2.0.

No

I would say that, taking into account standard order as defined in
Part 1 of the standard, that YAP is the only implementation behaving
correctly. However, is standard order (not arithmetic order)
meaningful in this context?

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