let couple_square x = x, x * x let couple_truc x = x, (x, x) let f i j f = i + j + int_of_float f let s3 (i, j, f) = i + j + int_of_float f, 30 type point2D = Point of float * float type int_or_infinity = Int of int | Infinity let div n d = if d = 0 then if n = 0 then failwith "0/0 undefined" else Infinity else Int (n / d) type form = Square of float | Circle of float | Rectangle of float * float let perimeter_rect w h = 2. *. (w +. h) let perimeter_circle r = 2. *. 3.14 *.r let perimeter_square c = perimeter_rect c c let perimeter form = match form with Rectangle (w, h) -> perimeter_rect w h | Circle r -> perimeter_circle r | Square c -> perimeter_square c type couleur = Coeur | Pique | Carreau | Trefle type carte = As of couleur | Numero of couleur * int | Roi of couleur | Dame of couleur | Valet of couleur let est_une_figure carte = match carte with As _ | Numero (_, _) -> false | _ -> true let couleur_carte carte = match carte with As c |Numero (c, _) |Roi c |Dame c |Valet c -> c let rec fib n = if n = 0 then 1 else if n = 1 then 1 else fib (n - 2) + fib (n - 1) type mycomplex = C of float * float let make_complex x y = C (x, y) let realpart z = let C(x, _) = z in x let imagpart z = let C(_, y) = z in y let c_add z1 z2 = make_complex (realpart z1 +. realpart z2) (imagpart z1 +. imagpart z2) let c_i = make_complex 0. 1. let translate z vector = c_add z vector let rotate0 z angle = c_mul (c_exp (c_scal angle c_i)) z