progs/fun-tests/hanoi.fun
author Christian Urban <christian.urban@kcl.ac.uk>
Tue, 15 Sep 2020 23:13:45 +0100
changeset 756 cb2918e02806
parent 742 155426396b5f
child 790 71ef7d9ef635
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;;