Last login: Wed Mar 22 15:06:25 on ttys000 Marco-Bellias-MacBook-Air:~ marcob$ ocaml OCaml version 4.02.2 # (3+4);; - : int = 7 # ((3+5))*2;; - : int = 16 # let x = 5;; val x : int = 5 # x*8;; - : int = 40 # let int x = 7;; val int : 'a -> int = # if x>7 then x else 'y';; Error: This expression has type char but an expression was expected of type int # if x>7 then 'x' else 'y';; - : char = 'y' # ();; - : unit = () # true or false;; Warning 3: deprecated: Pervasives.or Use (||) instead. - : bool = true # true && false;; - : bool = false # "hello" ^ "," ^ " bye";; - : string = "hello, bye" # (13,7);; - : int * int = (13, 7) # ("luigi",16);; - : string * int = ("luigi", 16) # let c = ("luigi",16);; val c : string * int = ("luigi", 16) # [c];; - : (string * int) list = [("luigi", 16)] # let f = fun x -> x+5;; val f : int -> int = # let g x = x+5;; val g : int -> int = # (g 3);; - : int = 8 # g 3 = f 3;; - : bool = true # let sum x y = x+y;; val sum : int -> int -> int = # let sum (x,y) = x+y;; val sum : int * int -> int = # let rec h x = h (x+1);; val h : int -> 'a = # (5 > 3) || (h 3)==5;; - : bool = true # (h 3)==5 || (5>3);; ^Z [1]+ Stopped ocaml Marco-Bellias-MacBook-Air:~ marcob$ ps -a PID TTY TIME CMD 15916 ttys000 0:00.03 login -pf marcob 15917 ttys000 0:00.01 -bash 15934 ttys000 3:50.82 /usr/local/bin/ocamlrun /usr/local/bin/ocaml 17492 ttys000 0:00.01 ps -a 17383 ttys001 0:00.02 login -pf marcob 17384 ttys001 0:00.01 -bash Marco-Bellias-MacBook-Air:~ marcob$ Kill -KILL 15934 Marco-Bellias-MacBook-Air:~ marcob$ ps -a PID TTY TIME CMD 15916 ttys000 0:00.03 login -pf marcob 15917 ttys000 0:00.02 -bash 17539 ttys000 0:00.00 ps -a 17383 ttys001 0:00.02 login -pf marcob 17384 ttys001 0:00.01 -bash [1]+ Killed: 9 ocaml Marco-Bellias-MacBook-Air:~ marcob$ ocaml OCaml version 4.02.2 # (* anche tipi array e record, oltre le liste *);; # let x = 5 in let prod x y = x*y in let rec fact = if n>0 then 1 else prod (fact (n-1)) n in fact x;; Error: Unbound value n # let x = 5 in let prod x y = x*y in let rec fact n = if n>0 then 1 else prod (fact (n-1)) n in fact x;; - : int = 1 # let x = 5 in let prod x y = x*y in let rec fact n = if n==0 then 1 else prod (fact (n-1)) n in fact x;; - : int = 120 # (*anche le funzioni sono valori *);; .... .(prossimo appuntamento gioved“ 30) ...........