magistraleinformaticanetworking:spm:ocaml-intro
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
Prossima revisione | Revisione precedente | ||
magistraleinformaticanetworking:spm:ocaml-intro [29/03/2011 alle 18:01 (14 anni fa)] – creata Marco Danelutto | magistraleinformaticanetworking:spm:ocaml-intro [31/03/2011 alle 08:33 (14 anni fa)] (versione attuale) – [SPM resources] Marco Danelutto | ||
---|---|---|---|
Linea 3: | Linea 3: | ||
==== Download ===== | ==== Download ===== | ||
Ocaml may be downloaded from the INRIA official [[http:// | Ocaml may be downloaded from the INRIA official [[http:// | ||
+ | |||
+ | ==== Documentation ==== | ||
+ | Documentation relative to Ocaml is available through the offical [[http:// | ||
+ | |||
+ | ==== Running programs ==== | ||
+ | |||
+ | === Using the interpreter === | ||
+ | Run **ocaml** from the shell prompt, then read the program text with a **#use " | ||
+ | |||
+ | === 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: | ||
+ | prova.ml skeletons.ml | ||
+ | backus: | ||
+ | Objective Caml version 3.11.1 | ||
+ | |||
+ | # #use " | ||
+ | val add : int -> int -> int = <fun> | ||
+ | Il valore della somma e' 5 | ||
+ | - : unit = () | ||
+ | # #quit;; | ||
+ | backus: | ||
+ | backus: | ||
+ | a.out prova.cmo skeletons.ml | ||
+ | prova.cmi prova.ml | ||
+ | backus: | ||
+ | # | ||
+ | backus: | ||
+ | Il valore della somma e' 5 | ||
+ | backus: | ||
+ | Il valore della somma e' 5 | ||
+ | backus: | ||
+ | let add x y = x + y;; | ||
+ | |||
+ | Printf.printf "Il valore della somma e' %d\n" (add 2 3);; | ||
+ | backus: | ||
+ | </ | ||
+ | ==== SPM resources ==== | ||
+ | Here you'll find Ocaml code related to the SPM course. | ||
+ | |||
+ | - [[skelfsem|Sample skeleton set functional semantics]] | ||
+ | - 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. | ||
+ | # | ||
+ | </ | ||
+ |
magistraleinformaticanetworking/spm/ocaml-intro.1301421704.txt.gz · Ultima modifica: 29/03/2011 alle 18:01 (14 anni fa) da Marco Danelutto