(*
let fact2 =
  let rec factt r n = if n > 0 then factt (r*n) (n-1) else r
  in factt 1
*)

let rec fact n = if n > 0 then n * fact(n-1) else 1

let rec factk n k = if n > 0 then factk (n-1) (fun x -> k (n*x)) else k 1

Scanf.scanf "%d%d" (fun x y -> (x, y))

let app () =
  let readprompt str =
    (print_string str; Scanf.scanf "%d" (fun x -> x))
  in print_int ((readprompt "first: ") + (readprompt "second: "))

This document was generated using caml2html