cwtests/cw05/hanoi.fun
changeset 856 23273e3a120f
equal deleted inserted replaced
855:1c0a684567d7 856:23273e3a120f
       
     1 // Towers of Hanoi in Fun
       
     2 
       
     3 def hanoi(n: Int, a: Int, b: Int, c: Int) : Void =
       
     4   if n != 0 then {
       
     5     hanoi(n - 1, a, c, b);
       
     6     print_int(a);
       
     7     print_char('-'); print_char('>'); // prints out "->"
       
     8     print_int(b);
       
     9     print_char('\n');
       
    10     hanoi(n - 1, c, b, a)
       
    11   } else skip;
       
    12 
       
    13 hanoi(4,1,2,3)