===== OCAML ===== ==== Download ===== Ocaml may be downloaded from the INRIA official [[http://caml.inria.fr/ocaml/|Ocaml]] web page (follow Download tab). Implementation exist running on Linux, Mac OS X and Windows. ==== Documentation ==== Documentation relative to Ocaml is available through the offical [[http://caml.inria.fr/resources/index.en.html|Ocaml documentation]] web page. ==== Running programs ==== === Using the interpreter === Run **ocaml** from the shell prompt, then read the program text with a **#use "filename.ml"** command. All the definitions in the file will be interpreted as if they were entered directly at the current ocaml interpreter prompt. === Compile to bytecode === Compile the program using the bytecode compiler **ocamlc**. Then run the resulting **a.out** either using **ocamlrun** command from the shell prompt or directly invoking the **./a.out** backus:SKammello marcod$ ls prova.ml skeletons.ml backus:SKammello marcod$ ocaml Objective Caml version 3.11.1 # #use "prova.ml";; val add : int -> int -> int = Il valore della somma e' 5 - : unit = () # #quit;; backus:SKammello marcod$ ocamlc prova.ml backus:SKammello marcod$ ls -t a.out prova.cmo skeletons.ml prova.cmi prova.ml backus:SKammello marcod$ head -1 a.out #!/usr/local/bin/ocamlrun backus:SKammello marcod$ ./a.out Il valore della somma e' 5 backus:SKammello marcod$ ocamlrun a.out Il valore della somma e' 5 backus:SKammello marcod$ cat prova.ml let add x y = x + y;; Printf.printf "Il valore della somma e' %d\n" (add 2 3);; backus:SKammello marcod$ ==== SPM resources ==== Here you'll find Ocaml code related to the SPM course. - [[skelfsem|Sample skeleton set functional semantics]] - [[http://backus.di.unipi.it/~marcod/SPM1011/dump2903.txt|terminal dump]] of the lesson given on Tue, March 29, 4pm - float aritmetic operators are indicated with a dot after the operator symbol (this was asked during March 29 lesson): # 0.0 +. 1.0 ;; - : float = 1. #