[mercury-users] Mercury Math Logarithms
Ralph Becket
rafe at cs.mu.OZ.AU
Tue Oct 22 18:07:44 AEST 2002
Noel Pinto, Tuesday, 22 October 2002:
> Hi,
>
> I am trying to have a number and find out the square root for it.
> I have written a code as below...
Noel... use this test harness for your experiments:
:- module foo.
:- interface.
:- import_module io.
:- pred main(io, io).
:- mode main(di, uo) is det.
:- implementation.
:- import_module ... % Fill in as appropriate.
main -->
{ my_computation(X) },
io__print(X),
io__nl.
and fill out the definition for my_computation/1 as appropriate.
For instance, to compute the square root of a constant:
:- pred my_computation(float).
:- mode my_computation(out) is det.
my_computation(X) :-
X = math__sqrt(123.4).
To square a constant
:- pred my_computation(float).
:- mode my_computation(out) is det.
my_computation(X) :-
X = 123.4 * 123.4.
And so forth. You're clearly getting totally confused by DCG notation
for IO, among other things. IO is complicated in Mercury. This harness
should help you make some progress.
Remember to change the type of the result of my_computation in the pred
declaration if you compute something other than a float.
- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list