progs/fun-tests/hanoi.fun
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 10 Jul 2023 18:48:05 +0100
changeset 914 245d2e9fa53a
parent 790 71ef7d9ef635
permissions -rw-r--r--
texupdate

// towers of hanoi in Fun

def hanoi(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 write("")

impure $ hanoi 4 1 2 3;;