(* ---------------- Tours de Hanoï, première version ----------------------*) let mouvement origine destination cpt = print_string("mouvement " ^origine^ " ---> " ^destination); print_newline(); cpt := !cpt + 1;; (*mouvement : string -> string -> unit = *) let hanoi nb_disques= let compt=ref 0 in let rec hanoi_aux n origine intermediaire destination = match n with | 1 -> begin mouvement origine destination compt; end | _ -> begin hanoi_aux (n-1) origine destination intermediaire; mouvement origine destination compt; hanoi_aux (n-1) intermediaire origine destination; end; in hanoi_aux nb_disques "A" "B" "C"; !compt;; (*hanoi : int -> int = *) print_string("Tours de Hanoi 2");; print_newline();; hanoi 2;; read_line();; print_string("Tours de Hanoï 3");; print_newline();; hanoi 3;; read_line();; print_string("Tours de Hanoï 4");; print_newline();; hanoi 4;; read_line();;