Hi,

I am doing some R & D in the coding for trignometry functions such 
as sine, cosine and tangent.

Sine    = opposite side of triangle / hypotenuse

Cosine    = adjacent side of triangle / hypotenuse

Tangent    = sin / cos

I am trying to write functions for them and since there are some 
operations in the module, I am trying to use them by passing 
values to it and get the output. The code is as below...

:- module trigo.

:- interface.
:- import_module io.

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

:- implementation.
:- import_module math, float, exception, string.

main -->
         print("Enter the angle : "), flush_output,
         read_float(angle), nl,
         print("Enter the hypotenuse : "), flush_output,
         read_float(hyp), nl,
         io__write_float(angle, hyp), nl,

         print(" Sin of "), print(" : "),
         { sinF(angle, hyp) = f1},
         io__write_float(f1).

:- func sinF(float::in, float::in) = float::out is det.
sinF(angle, hyp) = Float -->
         { math__sin(angle, hyp) = f1},
         Float = f1.

  I am confused as to how sin, cos and tan work in Mercury and how 
to write function for their calculation.
These are the errors which I get... Plz do help me rectify them.

trigo.m:023: Error: unrecognized declaration: func sinF((float :: 
in), (float :: in)) = float :: out is det.
trigo.m:024: Error: clause for predicate `trigo:=/4'
trigo.m:024:   without preceding `pred' declaration.
trigo.m:014: In clause for predicate `trigo:main/2':
trigo.m:014:   in argument 1 of call to predicate 
`read_float/3':
trigo.m:014:   error: undefined symbol `angle/0'.
trigo.m:016: In clause for predicate `trigo:main/2':
trigo.m:016:   in argument 1 of call to predicate 
`read_float/3':
trigo.m:016:   error: undefined symbol `hyp/0'.
trigo.m:017: In clause for predicate `trigo:main/2':
trigo.m:017:   in argument 1 of call to predicate 
`io:write_float/4':
trigo.m:017:   error: undefined symbol `angle/0'.
trigo.m:017: In clause for predicate `trigo:main/2':
trigo.m:017:   in argument 2 of call to predicate 
`io:write_float/4':
trigo.m:017:   error: undefined symbol `hyp/0'.
trigo.m:020: In clause for predicate `trigo:main/2':
trigo.m:020:   error: undefined symbol `sinF/2'.
trigo.m:020: In clause for predicate `trigo:main/2':
trigo.m:020:   in argument 1 of functor `sinF/2':
trigo.m:020:   error: undefined symbol `angle/0'.
trigo.m:020: In clause for predicate `trigo:main/2':
trigo.m:020:   in argument 2 of functor `sinF/2':
trigo.m:020:   error: undefined symbol `hyp/0'.
trigo.m:020: In clause for predicate `trigo:main/2':
trigo.m:020:   error: undefined symbol `f1/0'.
trigo.m:021: In clause for predicate `trigo:main/2':
trigo.m:021:   in argument 1 of call to predicate 
`io:write_float/3':
trigo.m:021:   error: undefined symbol `f1/0'.
trigo.m:024: In clause for predicate `trigo:=/4':
trigo.m:024:   in argument 1 of clause head:
trigo.m:024:   error: undefined symbol `sinF/2'.
trigo.m:024: In clause for predicate `trigo:=/4':
trigo.m:024:   in argument 1 of clause head:
trigo.m:024:   in argument 1 of functor `sinF/2':
trigo.m:024:   error: undefined symbol `angle/0'.
trigo.m:024: In clause for predicate `trigo:=/4':
trigo.m:024:   in argument 1 of clause head:
trigo.m:024:   in argument 2 of functor `sinF/2':
trigo.m:024:   error: undefined symbol `hyp/0'.
trigo.m:025: In clause for predicate `trigo:=/4':
trigo.m:025:   in argument 1 of functor `math:sin/2':
trigo.m:025:   error: undefined symbol `angle/0'.
trigo.m:025: In clause for predicate `trigo:=/4':
trigo.m:025:   in argument 2 of functor `math:sin/2':
trigo.m:025:   error: undefined symbol `hyp/0'.
trigo.m:025: In clause for predicate `trigo:=/4':
trigo.m:025:   error: undefined symbol `f1/0'.
trigo.m:026: In clause for predicate `trigo:=/4':
trigo.m:026:   in argument 2 of call to predicate `=/4':
trigo.m:026:   error: undefined symbol `f1/0'.
For more information, try recompiling with `-E'.

When I try compiling with mmc -E it displays to me the same 
errors.
I am using Mercury compiler 0.10.1.

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

