ex-l4-sol

# Differences

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

 ex-l4-sol [2014/10/28 15:36]t.cimoli ex-l4-sol [2015/10/08 15:20] (current) Both sides previous revision Previous revision 2014/10/28 15:39 t.cimoli 2014/10/28 15:36 t.cimoli 2014/10/28 15:35 t.cimoli 2014/10/28 15:28 t.cimoli 2014/10/23 13:08 giovanni.casu 2014/10/23 12:54 giovanni.casu 2014/10/23 12:17 giovanni.casu 2014/10/23 11:15 giovanni.casu 2014/10/22 20:46 giovanni.casu 2014/10/22 20:45 giovanni.casu 2014/10/22 00:25 giovanni.casu created Next revision Previous revision 2014/10/28 15:39 t.cimoli 2014/10/28 15:36 t.cimoli 2014/10/28 15:35 t.cimoli 2014/10/28 15:28 t.cimoli 2014/10/23 13:08 giovanni.casu 2014/10/23 12:54 giovanni.casu 2014/10/23 12:17 giovanni.casu 2014/10/23 11:15 giovanni.casu 2014/10/22 20:46 giovanni.casu 2014/10/22 20:45 giovanni.casu 2014/10/22 00:25 giovanni.casu created Line 41: Line 41: let multTre n = if (n=0) then 1 else multTreRec n;; let multTre n = if (n=0) then 1 else multTreRec n;; ​ - - .​let rec f pred n = if n < 10 then + - .​let rec f pred n = if n < 10 then (if pred n = true then 1 else 0 ) - if pred n = true then 1 else 0 else let cifra = n mod 10 in + ​else let cifra = n mod 10 - if pred cifra = true then 1 + f pred (n/10) else f pred (n/10);; ​ + in if pred cifra = true then 1 + f pred (n/​10) ​ + else f pred (n/10);; ​ - Esempio senza pattern matching ​let rec gcd n m = - Esempio senza pattern matching ​let rec gcd n m = if n=0 then m else if n=0 then m else