changeset 894 | 02ef5c3abc51 |
parent 893 | 54a483a33763 |
child 895 | 2f5a87ecdc81 |
893:54a483a33763 | 894:02ef5c3abc51 |
---|---|
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) |