open Sigma let last = Array.length Sys.argv - 1;; if last < 1 then exit 0;; match Sys.argv.(1) with | "-carre" -> let f x = let n = int_of_string x in n * n in print_int (sigma f Sys.argv 2 last) | "-moyenne" -> let r = sigma int_of_string Sys.argv 2 last in print_float (float r /. float (Array.length Sys.argv - 2)) | _ -> print_int (sigma int_of_string Sys.argv 1 last) ;; print_newline();;
% ocamlc -o calculette calculette.ml % calculette -carre 1 2 3 4 5 6 91