progs/fun-tests/hanoi.fun
author Christian Urban <christian.urban@kcl.ac.uk>
Sun, 11 Oct 2020 09:10:08 +0100 (2020-10-11)
changeset 778 3e5f5d19f514
parent 742 b5b5583a3a08
child 790 31a9f89776a3
permissions -rw-r--r--
updated
// 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;;