progs/fun-tests/hanoi.fun
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 02 Dec 2022 16:26:20 +0000
changeset 901 33cff35bdc1a
parent 790 31a9f89776a3
permissions -rw-r--r--
updated

// 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;;