*Maximum de 2 entiers: #let max a b = if(a>=b) then a else b;; max : 'a -> 'a -> 'a = test: #max 98 45;; - : int = 98 *Controle de type: #let equal x y = if x = y then true else false;; equal : 'a -> 'a -> bool = #let Entre3et5 x = (x > 3) & (x < 5);; Entre3et5 : int -> bool = #let Test0 x y = if(Test1 x) then 3 else 4;; Toplevel input: >let Test0 x y = if(Test1 x) then 3 else 4;; > ^^^^^ The value identifier Test1 is unbound. #let Test1 x = if Entre3et5 x = false then 1 else 2;; Test1 : int -> int = #let Test2 x = if equal (Entre3et5 x) false then true else false;; Test2 : int -> bool = #let Test3 x y = let z = if(Test1 x) then 3 else 4 in z +. y;; Toplevel input: >let Test3 x y = let z = if(Test1 x) then 3 else 4 in z +. y;; > ^^^^^^^ This expression has type int, but is used with type bool. #let Test4 x y = if equal x y then Test1 x else Test2 y;; Toplevel input: >let Test4 x y = if equal x y then Test1 x else Test2 y;; > ^^^^^^^ This expression has type bool, but is used with type int. #let Test5 x = if not (Entre3et5 x) then 1 else 2;; Test5 : int -> int = #let Test 6 x y = if Entre3et5 x then not(Entre3et5 y);; Toplevel input: >let Test 6 x y = if Entre3et5 x then not(Entre3et5 y);; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This expression has type unit, but is used with type bool. #let Test7 x y = x + if(x>=y) then "bonjour" else "au revoir";; Toplevel input: >let Test7 x y = x + if(x>=y) then "bonjour" else "au revoir";; > ^^^^^^^^^ This expression has type string, but is used with type int *Fonctions booleennes: 1. #let ET a b = if a then b else false;; ET : bool -> bool -> bool = #let OU a b = if a then true else b;; OU : bool -> bool -> bool = #let NON a = if a then false else true;; NON : bool -> bool = 3. #let OUEX a b = if a then not(b) else b;; OUEX : bool -> bool -> bool = #let IMPLIQUE a b = if a then b else true;; IMPLIQUE : bool -> bool -> bool = #let EQUIVALENT a b = if a then b else not(b);; EQUIVALENT : bool -> bool -> bool = 4. #let NOTaORb a b = not(a) & not(b);; NOTaORb : bool -> bool -> bool = #let NOTaETb a b = not(a) or not(b);; NOTaETb : bool -> bool -> bool = #let aIMPLIQUEb a b = not(a) or b;; aIMPLIQUEb : bool -> bool -> bool = #let aIMPLIQUEb2 a b = not(a & not(b));; aIMPLIQUEb2 : bool -> bool -> bool = *Aire d'une couronne: #let AireCouronne r R = let AireDisc x = let PI = 3.14159 in 2 *. PI *. x *. x in (AireDisc R) -. (AireDisc r);; Pas encore bon !