(* staged computation *)
let rec fact n = if n = 0 then 1 else n * fact(n - 1)
let stage n =
let m = fact n
in function k -> fact k * m
(* try:
let f = stage 10;;
f 4;;
f 5;;
f 6;;
(fact 10 = 3628800 is only computed once, and
f = function k -> fact k * 3628800)
*)