progs/fun-tests/hanoi.fun
changeset 790 31a9f89776a3
parent 742 b5b5583a3a08
equal deleted inserted replaced
789:f0696713177b 790:31a9f89776a3
     1 // towers of hanoi in Fun
     1 // towers of hanoi in Fun
     2 
     2 
     3 let rec hanoi = fun n a b c ->
     3 def hanoi(n, a, b, c) =
     4   if n != 0 then (
     4   if n != 0 then {
     5     hanoi (n - 1) a c b;
     5     hanoi (n - 1) a c b;
     6     print_endline ("Move disk from pole " ^ (show a) ^ " to pole " ^ (show b));
     6     print_endline ("Move disk from pole " ^ (show a) ^ " to pole " ^ (show b));
     7     hanoi (n - 1) c b a
     7     hanoi (n - 1) c b a
     8   ) else ();;
     8   } else write("")
     9 
     9 
    10 impure $ hanoi 4 1 2 3;;
    10 impure $ hanoi 4 1 2 3;;