Re: bad pi
- From: "An Ony" <nowhere@xxxxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 11:28:25 +0200
"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
.
- References:
- bad pi
- From: An Ony
- Re: bad pi
- From: Jan Wielemaker
- bad pi
- Prev by Date: Re: bad pi
- Next by Date: Re: What should the semantics of hierarchical modules be?
- Previous by thread: Re: bad pi
- Next by thread: Re: bad pi
- Index(es):
Relevant Pages
|
|