Basic Ocaml Program

by matt392 in Circuits > Software

7 Views, 0 Favorites, 0 Comments

Basic Ocaml Program

ocaml.png

Basic Ocaml program.

Be sure to change the extension to ".ml" from ".txt"!

To compile on Linux, go to the Terminal and type:

First change the extension: mv test-change-extensioin-to-ml.txt test.ml

Next compile the code using the OCaml compiler: ocamlc -o test test.ml

Run the executable (remember the dot slash before the executable name): ./test

ocaml.png
let _ = print_endline "Hello my name is Matt."
let _ = print_int (40*35)
let _ = print_endline "\r"
let _ = print_float (1400.0 *. 0.65)
let _ = print_endline "\r"
let _ = print_int (910 * 4)
let _ = print_endline "\r"