ex-l2-plus-sol

# Differences

This shows you the differences between two versions of the page.

 ex-l2-plus-sol [2014/10/08 12:31]giovanni.casu ex-l2-plus-sol [2015/10/08 15:20] (current) Both sides previous revision Previous revision 2014/10/20 11:00 giovanni.casu 2014/10/08 12:31 giovanni.casu 2014/10/08 12:06 giovanni.casu 2014/10/08 12:01 giovanni.casu created Next revision Previous revision 2014/10/20 11:00 giovanni.casu 2014/10/08 12:31 giovanni.casu 2014/10/08 12:06 giovanni.casu 2014/10/08 12:01 giovanni.casu created Line 12: Line 12: - Esponenziale:<​code ocaml>​let exp x n = let rec exp' x n acc = if (n=0) then 1 - Esponenziale:<​code ocaml>​let exp x n = let rec exp' x n acc = if (n=0) then 1 else exp' x (n-1) x*acc in exp' x n x;;​ else exp' x (n-1) x*acc in exp' x n x;;​ - - Fibonacci:<​code ocaml>​let fib n = let rec fib' n a acc = if(n=0) then acc + - Fibonacci:<​code ocaml>​let fib n = let rec fib' n a acc = if(n=0) then a else fib' (n-1) acc (a+acc) in fib' n 0 1;;​ else fib' (n-1) acc (a+acc) in fib' n 0 1;;​ - Real:<​code ocaml>​let real n = let rec real' n acc = if(n=0) then acc - Real:<​code ocaml>​let real n = let rec real' n acc = if(n=0) then acc