28/11/2021, 16:16
let rec rev l = match l with
[] -> []
| h::t -> rev t @ [h];;
let rec f l = match l with
[] -> 0
| h::t -> let k = rev l in match k with
[] -> 0
| k::v -> k * 2 + f v;;
29/11/2021, 01:09
29/11/2021, 11:02
29/11/2021, 11:33
let reverse lst = reverseAcc [] lst
let rec reverseAcc acc lst =
match lst with
| [] -> acc
| h::t = reverseAcc (h @ acc) t
let twoPowers n =
let rec twoPowersHelper s n = if n > 0 then (s @ twoPowersHelper (2 * s) (n - 1)) else [] in
twoPowersHelper 1 n
08/12/2021, 15:49
Skuola.net News è una testata giornalistica iscritta al Registro degli Operatori della Comunicazione.
Registrazione: n° 20792 del 23/12/2010.
©2000—
Skuola Network s.r.l. Tutti i diritti riservati. — P.I. 10404470014.
Powered by phpBB © phpBB Group - Privacy policy - Cookie privacy
phpBB Mobile / SEO by Artodia.