Anonymous user
Modulinos: Difference between revisions
Added OCaml
(Added OCaml) |
|||
Line 633:
console.log("Test: The meaning of life is " + sm.meaningOfLife());</lang>
=={{header|OCaml}}==
scriptedmain.ml
<lang ocaml>(*
Compile:
ocamlc -o scriptedmain -linkall str.cma scriptedmain.ml
Run:
./scriptedmain
*)
let meaning_of_life = 42
let rec main () = print_endline ("Main: The meaning of life is " ^ string_of_int meaning_of_life)
let _ =
let program = Sys.argv.(0) in
let re = Str.regexp "scriptedmain" in
try let _ = Str.search_forward re program 0 in
main ()
with _ -> ()</lang>
test.ml
<lang ocaml>(*
Compile:
ocamlc -o test -linkall str.cma scriptedmain.ml test.ml
Run:
./test
*)
let rec main () = print_endline ("Test: The meaning of life is " ^ string_of_int Scriptedmain.meaning_of_life)
let _ =
let program = Sys.argv.(0) in
let re = Str.regexp "test" in
try let _ = Str.search_forward re program 0 in
main ()
with _ -> ()</lang>
=={{header|Octave}}/{{header|MATLAB}}==
|