(* fonctions *) (fun x y -> 3 * x + 5 * y) 1 2;; (fun x y -> 2 * x + 7) 9 18;; (fun x y -> 2 * x + 7) 9 true;; (* inference de type *) fun x y z -> let x = x < y and y = z in if x then y else z;; (* fonction nommée *) let carre = fun x -> x *. x;; let discriminant a b c = (carre b) -. 4. *. a *. c;; let nb_sol a b c = let delta = discriminant a b c in if delta = 0. then 1 else if delta < 0. then 0 else 2;; let carre_fun f = (fun x -> f (f x));; (* function *) let f = function 0 -> "vaut 0" | 1 -> "vaut 1" | y -> (string_of_int y)^" est différent de 0,1";; (* fonction récursive *) let rec pow2_log x = if x = 0 then 1 else let y = pow2_log (x / 2) in let p = y * y in if x mod 2 = 0 then p else p * 2;;