Re: bad pi




"Jan Wielemaker" <jan@xxxxxxxxxxxx> schreef in bericht
news:slrnd74m1e.1b4.jan@xxxxxxxxxxxxxxx
> On 2005-04-29, An Ony <nowhere@xxxxxxxxxxxxx> wrote:
>> Hi,
>>
>> (there's actually not one programming language I know that can do this,
>> but)
>> is there any way to make prolog give me
>> X = 5*pi
>> when I ask
>> X is 3*pi + 2*pi
>> and not
>> X = 15.708
>
> As such, no. It would be broken as is/2 is supposed to return a number.
> You'd either have to write your own (symbolic) evaluator or you can change
> the printing:
>
> portray(X) :-
> float(X),
> Y is X/pi,
> abs(Y*pi - X) < 1e-10,
> format('~w*pi', [Y]).
>
> ?- A is 2*pi + 3*pi.
>
> A = 5*pi
>


Thx, I'm gonna check that out


.



Relevant Pages

  • Re: bad pi
    ... > (there's actually not one programming language I know that can do this, ... > is there any way to make prolog give me ... floats rarely match using == ... ... Prev by Date: ...
    (comp.lang.prolog)
  • Re: bad pi
    ... >(there's actually not one programming language I know that can do this, ... >is there any way to make prolog give me ... Cheers, Andreas ... Prev by Date: ...
    (comp.lang.prolog)
  • bad pi
    ... (there's actually not one programming language I know that can do this, ... is there any way to make prolog give me ... TIA ... Prev by Date: ...
    (comp.lang.prolog)
  • Re: Is Prolog good for AI? (was: Minsky still posting)
    ... >> widely viewed as a failure. ... programming language was "a version of Prolog". ...
    (comp.lang.prolog)
  • Algorithm transformation
    ... (sorry if the syntax is prolog like, but it is the programming language ... And the target is to obtain the set of rules for the addition of one ...
    (comp.theory)