open Format module type TComplex = sig type t val zero : t val cons : float -> float -> t val oppose : t -> t val plus : t -> t -> t val modu : t -> float end module Complex : TComplex = struct type t = float * float let zero = (0.,0.) let cons r i = (r,i) let oppose (r,i) = (-.r,-.i) let plus (r_1,i_1) (r_2,i_2) = (r_1+.r_2,i_1+.i_2) let modu (r,i) = sqrt (r*.r +. i*.i) end let jeu () = ( let c1 = Complex.cons 3.14 2.0 and c2 = Complex.cons 6.17 (-2.7) in let c3 = Complex.plus c1 c2 and modulc2 = Complex.modu c2 in printf "%f" modulc2; print_newline(); ) let main = ( printf "debut du prog\n"; jeu(); printf "fin du prog\n"; exit 0; )