(* /!\ Code écrit par Lilian BESSON - LSV & CMLA & ENS de Cachan. Par respect des droits de propriétés intellectuelles, conservez ce bordereau si vous utilisez tout ou une partie de ce fichier. *) (* *) (* Plot : MOcaml v1.0 *) (* *) (** {7 Plot : code ml pour ocamlc} *) (** *) (** Plot : Projet MOcaml *)(** ENS de Cachan - 2012 L3 Informatique Projet MOcaml v1.0.4 *)(** Besson Lilian. Inspiré de 'meta_plot.c' et 'script_metaplot.sh' écrits par Lilian Besson en Février 2012. (c) Naereen Corp. *) (* * Ce module fait partis du projet MOcaml, et utilise les modules ANSITerminal, et . * Pour plus de détails, voir la documentation du projet MOcaml, en ligne ou dans les README. *) (* ******************************************************************************************************************************************* *) (** Utilise le module ANSITerminal. *) if !(Sys.interactive) then failwith "[MOcaml Plot] Ce programme ne peut pas etre utilise en mode toplevel.";; open MOcamlPlot;; let tabarg = ((fun a -> (try (Array.sub a 1 (-1 + Array.length a)) with _ -> [||] ) ) Sys.argv);; let usage = " USAGE : ./PlotMOcaml [options] \"chaine_de_caractere_pour_la_fonction_a_tracer\" [minX maxX] OPTIONS : ========= -h Affiche cette aide, --help Affiche cette aide, -? Affiche cette aide, -n Non coloré, -e Produit un exécutable qui affiche le graphique. Plot : Projet MOcaml ENS de Cachan - 2012 L3 Informatique Projet MOcaml v0.9.7 Ce programme permet le tracé dans un terminal du graphe d'une fonction. Si le terminal supporte les couleurs ANSI, le graphe est coloré. Le module MOcamlPlot peut aussi être utilisé directement dans un autre programme Ocaml. Pour tout contacts, corrections, ou questions : , (c) et (r) 2012 Naereen Corp. by Lilian Besson. ";; let gere_help = function | "-h" | "--help" | "?" | "-?" | "--?" | "--h" -> print_string usage; exit 0; | _ -> ();; match (Array.length tabarg) with | 0 -> print_string "[MOcaml Plot] Aucun argument.\n"; exit 1; | 1 -> let chaine_f = (tabarg.(0)) in gere_help chaine_f; Printf.printf "[MOcaml Plot] Tracé du graphe pour %s en cours...\n" chaine_f; flush_all (); polyPlot chaine_f; | 2 -> let chaine_f = (tabarg.(0)) in gere_help chaine_f; Printf.printf "[MOcaml Plot] Tracé du graphe pour %s en cours...\n" (tabarg.(0)); flush_all (); polyPlot (tabarg.(0)); | 3 -> let chaine_f = (tabarg.(0)) in gere_help chaine_f; Printf.printf "[MOcaml Plot] Tracé du graphe pour %s sur [%f; %f] en cours...\n" (tabarg.(0)) (float_of_string(tabarg.(1))) (float_of_string(tabarg.(2))); flush_all (); polyPlot (tabarg.(0)) ~range:((float_of_string(tabarg.(1))), (float_of_string(tabarg.(2)))); | _ -> let chaine_f = (tabarg.(0)) in gere_help chaine_f; ANSITerminal.print_string [ANSITerminal.Bold] ""; ANSITerminal.print_string [ANSITerminal.Bold] "[MOcaml Plot] Les arguments après le troisième ne sont plus utiles !!\n"; Printf.printf "[MOcaml Plot] Tracé du graphe pour %s sur [%f; %f] en cours...\n" (tabarg.(0)) (float_of_string(tabarg.(1))) (float_of_string(tabarg.(2))); flush_all (); polyPlot (tabarg.(0)) ~range:((float_of_string(tabarg.(1))), (float_of_string(tabarg.(2))));; exit 0;; (*polyPlot "sin(x)" ~range:(-3--9);;*) (* Merci a Romain Vernoux pour l'idée sur la surcharge. *) (* /!\ Code écrit par Lilian BESSON - LSV & CMLA & ENS de Cachan. Par respect des droits de propriétés intellectuelles, conservez ce bordereau si vous utilisez tout ou une partie de ce fichier. *)