let rec fold (oper : int -> int -> int) (x0 : int) f = function | [] -> x0 | x :: rest -> oper (f x) (fold oper x0 f rest);; let fold (oper : int -> int -> int) (x0 : int) f = let rec aux = function | [] -> x0 | x :: rest -> oper (f x) (aux rest) in aux;; let sigma f l = fold ( + ) 0 f l;; let pi f l = fold ( * ) 1 f l;; |