

On Sat, 19 Oct 2002 Fergus Henderson wrote :
>On 19-Oct-2002, Noel  Pinto <cool4life@rediffmail.com> wrote:
> > 1) I want to know more of Mathematical Constants. There are 
>two
> > constants, one for Pythagorus and Natural Algorithms.
>
>It's natural *logarithms*, not *algorithms*.
>
> > Plz do explain how do I implement them?
>
>You don't.  We, the Mercury implementors, implement them.
>
>If you are asking how you might *use* these values...
>did you do any mathematics at school?
>If not, then I suggest you do not try to use these values!

I did have Mathematics in school. I just wanted to know how do I 
use them with the mathematical constants defined in math.m

>If you a moderate amount of maths at school, then you should
>know that "e" and "pi" are well-known mathematical constants
>which appear in common formulae.  For example, pythagorus's 
>number
>"pi" can be used for calculating the circumference or area of a 
>circle,
>given its radius.
>
> 	:- func area(float) = float.
> 	area(Radius) = math__pi * Radius * Radius.
>
> 	:- func circumference(float) = float.
> 	circumference(Radius) = 2.0 * math__pi * Radius.
Thanks

I have tried using them in a code, but now I get one error. Plz do 
help me rectify it. The code is below and with the error...

Code
:- module 'Nex_int'.

:- interface.
:- import_module io.
:- pred main(io__state, io__state).
:- mode main(di, uo) is det.

:- implementation.
:- import_module math, float.
:- func circumference(float) = float.
  :- mode circumference(in) = out is det.
main --> { Radius = 10.0, circumference(Radius) = 2.0 * math__pi * 
Radius}.

The error is ...
Nex_int.m:010: Error: no clauses for function 
`Nex_int:circumference/1'.

Similarly I do have some more queries...

1) I have tried using math__round but I do get the same error as 
above. That piece of code is below:
main --> { Num = 10.5, NumRound(Num) = math__round(Num) }.
Plz do suggest a solution.

2) I would like to know how do I use math__ceiling, math__floor 
and math__truncate? It is a bit confusing as to how to apply the 
logic for writng the code.

Regards,

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
--------------------------------------------------------------------------

