(module forma_1_factorial (fn fact_acc (doc "Tail-recursive factorial accumulator: fact_acc(n, acc) = n!*acc.") (type (fn-type (params (own (con Int)) (own (con Int))) (ret (own (con Int))))) (params n acc) (body (if (app eq n 0) acc (tail-app fact_acc (app - n 1) (app * acc n))))) (fn fact (doc "Factorial of a non-negative Int.") (type (fn-type (params (own (con Int))) (ret (own (con Int))))) (params n) (body (app fact_acc n 1))) (fn main (type (fn-type (params) (ret (own (con Unit))) (effects IO))) (params) (body (seq (app print (app fact 5)) (app print (app fact 10))))))