

On Mon, 21 Oct 2002 Nancy Mazur wrote :
>* Noel  Pinto <cool4life@rediffmail.com> [2002-10-21 15:42]:
> > Hi,
> >
> >  I want to write a module which would have a number which 
>would
> > be a float and then it should be rounded to the nearest 
>number. At
> > each stage it should be displayed on the screen. But I get 
>errors
> > , plz do help me solve it.
> >
> > :- module 'Nex_int'.
> >
> > :- interface.
> > :- import_module io.
> > :- pred main(io__state, io__state).
> > :- mode main(di, uo) is det.
> >
> > :- implementation.
> > :- import_module math, float.
> > main --> { Radius = 10.5 }, print(Radius), {Radius =
> > math__round(Radius)}, print(Radius).
> >
> > Here is the error...
> > Nex_int.m:006: In `main(di, uo)':
> > Nex_int.m:006:   error: determinism declaration not 
>satisfied.
> > Nex_int.m:006:   Declared `det', inferred `semidet'.
> > Nex_int.m:010:   In the return value of call to function
> > `math:round/1':
> > Nex_int.m:010:   unification with `Radius' can fail.
> >
> > Whatever I try by changing its determinism, it does not solve 
>the
> > problem. Plz do help.
Here is the error I get...
Nex_int.m:012: In clause for predicate `Nex_int:main/2':
Nex_int.m:012:   error: ambiguous overloading causes type 
ambiguity.
Nex_int.m:012:   Possible type assignments include:
Nex_int.m:012: RoundedRadius :: float or (pred float)

>Mercury is a pure logic programming language, which means that 
>the value
>of variables can only be attributed once during the lifetime of 
>a
>variable. Take pure mathematics, what you write there is that
>you assign value 10.5 to Radius, and then you want to verify 
>the
>equality whether or not Radius = math_round(Radius). Of course 
>the
>answer is no! (10.5 will never be equal to the rounded value of 
>10.5!).
>
>You might perhaps consider reading more about the basics of 
>logic
>programming languages. In the FAQ of comp.lang.prolog you may 
>find some
>interesting references to books introducing you to logic 
>programming, or
>more specifically Prolog (which is also a logic programming 
>language).
>==> http://www.cs.kuleuven.ac.be/~remko/prolog/faq/

I will view the website...

Thanks,

Noel

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users@cs.mu.oz.au
administrative address: owner-mercury-users@cs.mu.oz.au
unsubscribe: Address: mercury-users-request@cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request@cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------

