Towers of Hanoi: Difference between revisions
Perl 5: Changed to permit calling with one argument. Perl 6: Added.
Underscore (talk | contribs) (Perl 5: Changed to permit calling with one argument. Perl 6: Added.) |
|||
Line 680:
=={{header|Perl}}==
<lang perl>
=={{header|Perl 6}}==
{{works with|Rakudo|#22 "Thousand Oaks"}}
<lang perl6>subset Peg of Int where * == 1|2|3;
multi hanoi (0, Peg $a, Peg $b, Peg $c) { }
multi hanoi (Int $n, Peg $a = 1, Peg $b = 2, Peg $c = 3) {
hanoi $n - 1, $a, $c, $b;
say "Move $a to $b.";
hanoi $n - 1, $c, $b, $a;
}</lang>
=={{header|PHP}}==
|