arithmetic predicate does not always compute unbound arguments
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: comp.lang.prolog
From:
metaperl <scheme... @gmail.com>
Date: Mon, 2 Nov 2009 12:40:03 -0800 (PST)
Local: Mon, Nov 2 2009 3:40 pm
Subject: arithmetic predicate does not always compute unbound arguments
The wonderful ability of Prolog to flexibly compute A given B or vice versa seems to fail with arithmetic: c_to_f(C,F) :- F is C * 9 / 5 + 32.
It would be nice if there were some way to get C given F and vice versa.
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.prolog
From:
Markus Triska <tri... @logic.at>
Date: Mon, 02 Nov 2009 21:59:25 +0100
Local: Mon, Nov 2 2009 3:59 pm
Subject: Re: arithmetic predicate does not always compute unbound arguments
metaperl <scheme
... @gmail.com> writes:
> c_to_f(C,F) :-
> F is C * 9 / 5 + 32.
> It would be nice if there were some way to get C given F and vice > versa.
Indeed, therefore we have the CLP(Q/R/FD) constraint libraries: :- use_module(library(clpq)).
c_f(C, F) :- { F = C * 9 / 5 + 32 }.
Examples:
?- c_f(C, F). %@ {F=32+9 rdiv 5*C}.
?- c_f(23, F). %@ F = 367 rdiv 5.
?- c_f(C, 23). %@ C = -5.
-- comp.lang.prolog FAQ: http://www.logic.at/prolog/faq/
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.prolog
From:
Chip Eastham <hardm... @gmail.com>
Date: Thu, 5 Nov 2009 08:55:36 -0800 (PST)
Local: Thurs, Nov 5 2009 11:55 am
Subject: Re: arithmetic predicate does not always compute unbound arguments
On Nov 2, 3:59 pm, Markus Triska <tri... @logic.at> wrote:
> metaperl <scheme
... @gmail.com> writes:
> > c_to_f(C,F) :-
> > F is C * 9 / 5 + 32.
> > It would be nice if there were some way to get C given F and vice > > versa.
> Indeed, therefore we have the CLP(Q/R/FD) constraint libraries:
> :- use_module(library(clpq)).
> c_f(C, F) :- { F = C * 9 / 5 + 32 }.
At a more elementary level you might have rules that check to see whether C and/or F is free vs. bound. E.g. c_f(C,F) :- ( var(C) -> C is (F - 32)*5/9 ; F is (C*9/5) + 32 ).
regards, chip
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: comp.lang.prolog
From:
Cesar Rabak <csra... @yahoo.com.br>
Date: Fri, 06 Nov 2009 12:32:50 -0200
Local: Fri, Nov 6 2009 9:32 am
Subject: Re: arithmetic predicate does not always compute unbound arguments
Chip Eastham escreveu:
> On Nov 2, 3:59 pm, Markus Triska <tri
... @logic.at> wrote:
>> metaperl <scheme
... @gmail.com> writes:
>>> c_to_f(C,F) :-
>>> F is C * 9 / 5 + 32.
>>> It would be nice if there were some way to get C given F and vice
>>> versa.
>> Indeed, therefore we have the CLP(Q/R/FD) constraint libraries:
>> :- use_module(library(clpq)).
>> c_f(C, F) :- { F = C * 9 / 5 + 32 }.
> At a more elementary level you might have rules > that check to see whether C and/or F is free vs. > bound. E.g.
> c_f(C,F) :- > ( var(C) -> C is (F - 32)*5/9 > ; F is (C*9/5) + 32 ).
Hi Chip, Although this is syntactical correct Prolog, IMNHO this is no longer logic programming but a procedural construct done in Prolog language.
You must
Sign in before you can post messages.
You do not have the permission required to post.