User Tools

Site Tools


ex-l4-sol

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ex-l4-sol [2014/10/28 15:36]
t.cimoli
ex-l4-sol [2015/10/08 15:20] (current)
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;;
 </​code>​ </​code>​
-  - .<code ocaml>​let rec f pred n = if n < 10 then  +  - .<code ocaml>​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);; </​code>​+                         in if pred cifra = true then 1 + f pred (n/​10) ​ 
 +                                                 else f pred (n/10);; </​code>​
   - Esempio senza pattern matching <code ocaml>​let rec gcd n m =   - Esempio senza pattern matching <code ocaml>​let rec gcd n m =
   if n=0 then m else   if n=0 then m else
ex-l4-sol.txt · Last modified: 2015/10/08 15:20 (external edit)