progs/hanoi.fun
author Christian Urban <christian.urban@kcl.ac.uk>
Thu, 16 Apr 2020 19:15:46 +0100
changeset 721 e3c64f22dd31
parent 706 b560f78781b9
permissions -rw-r--r--
added slides from Rochester

// towers of hanoi in Fun

let rec hanoi = fun n a b c ->
  if n != 0 then (
    hanoi (n - 1) a c b;
    print_endline ("Move disk from pole " ^ (show a) ^ " to pole " ^ (show b));
    hanoi (n - 1) c b a
  ) else ();;

impure $ hanoi 4 1 2 3;;