Towers of Hanoi: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 1,397:
putStrLn $ "Move " ++ show a ++ " to " ++ show b
hanoiM' (n - 1) c b a</lang>
 
=={{header|Elena}}==
ELENA 4.x :
Line 1,578 ⟶ 1,579:
| a, b -> printf "Move disc from %A to %A\n" a b)
0</lang>
 
=={{header|FALSE}}==
<lang false>["Move disk from "$!\" to "$!\"
"]p: { to from }
[n;0>[n;1-n: @\ h;! @\ p;! \@ h;! \@ n;1+n:]?]h: { via to from }
4n:["right"]["middle"]["left"]h;!%%%</lang>
 
=={{header|Factor}}==
Line 1,607 ⟶ 1,602:
1->3</pre>
 
=={{header|FōrmulæFALSE}}==
<lang false>["Move disk from "$!\" to "$!\"
 
"]p: { to from }
In [http://wiki.formulae.org/Towers_of_Hanoi this] page you can see the solution of this task.
[n;0>[n;1-n: @\ h;! @\ p;! \@ h;! \@ n;1+n:]?]h: { via to from }
 
4n:["right"]["middle"]["left"]h;!%%%</lang>
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text ([http://wiki.formulae.org/Editing_F%C5%8Drmul%C3%A6_expressions more info]). Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for transportation effects more than visualization and edition.
 
The option to show Fōrmulæ programs and their results is showing images. Unfortunately images cannot be uploaded in Rosetta Code.
 
=={{header|Forth}}==
Line 1,776 ⟶ 1,769:
Towers of Hanoi puzzle solved.
</pre>
 
=={{header|Fōrmulæ}}==
 
In [http://wiki.formulae.org/Towers_of_Hanoi this] page you can see the solution of this task.
 
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text ([http://wiki.formulae.org/Editing_F%C5%8Drmul%C3%A6_expressions more info]). Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for transportation effects more than visualization and edition.
 
The option to show Fōrmulæ programs and their results is showing images. Unfortunately images cannot be uploaded in Rosetta Code.
 
=={{header|GAP}}==
Line 2,630 ⟶ 2,631:
 
:- end_object.</lang>
 
 
=={{header|LOLCODE}}==
Line 3,339:
};
};</lang>
 
=={{header|Perl 6}}==
<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|Phix}}==
Line 3,549 ⟶ 3,539:
(println 'Move 'disk 'from A 'to B)
(move (dec N) C B A) ) )</lang>
 
=={{header|Pop11}}==
<lang pop11>define hanoi(n, src, dst, via);
if n > 0 then
hanoi(n - 1, src, via, dst);
'Move disk ' >< n >< ' from ' >< src >< ' to ' >< dst >< '.' =>
hanoi(n - 1, via, dst, src);
endif;
enddefine;
 
hanoi(4, "left", "middle", "right");</lang>
 
=={{header|PL/I}}==
Line 3,583 ⟶ 3,562:
end tower;</lang>
 
=={{Headerheader|PlainTeX}}==
 
<lang TeX>\newcount\hanoidepth
Line 3,604 ⟶ 3,583:
\hanoi{5}
\end</lang>
 
=={{header|Pop11}}==
<lang pop11>define hanoi(n, src, dst, via);
if n > 0 then
hanoi(n - 1, src, via, dst);
'Move disk ' >< n >< ' from ' >< src >< ' to ' >< dst >< '.' =>
hanoi(n - 1, via, dst, src);
endif;
enddefine;
 
hanoi(4, "left", "middle", "right");</lang>
 
=={{header|PostScript}}==
Line 4,268 ⟶ 4,258:
(hanoi 4 'left 'middle 'right)
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<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|Rascal}}==
Line 4,887 ⟶ 4,888:
14: Move disc from A to C
15: Move disc from B to C</pre>
 
=={{header|Standard ML}}==
fun hanoi(0, a, b, c) = [] |
Line 5,107 ⟶ 5,109:
EndIf
Return</lang>
 
=={{header|UNIX Shell}}==
{{works with|bash}}
Line 5,255 ⟶ 5,258:
Move from left peg to right peg.
</pre>
 
=={{header|XSLT}}==
<lang xml><xsl:template name="hanoi">
<xsl:param name="n"/>
<xsl:param name="from">left</xsl:param>
<xsl:param name="to">middle</xsl:param>
<xsl:param name="via">right</xsl:param>
<xsl:if test="$n &gt; 0">
<xsl:call-template name="hanoi">
<xsl:with-param name="n" select="$n - 1"/>
<xsl:with-param name="from" select="$from"/>
<xsl:with-param name="to" select="$via"/>
<xsl:with-param name="via" select="$to"/>
</xsl:call-template>
<fo:block>
<xsl:text>Move disk from </xsl:text>
<xsl:value-of select="$from"/>
<xsl:text> to </xsl:text>
<xsl:value-of select="$to"/>
</fo:block>
<xsl:call-template name="hanoi">
<xsl:with-param name="n" select="$n - 1"/>
<xsl:with-param name="from" select="$via"/>
<xsl:with-param name="to" select="$to"/>
<xsl:with-param name="via" select="$from"/>
</xsl:call-template>
</xsl:if>
</xsl:template></lang>
 
<xsl:call-template name="hanoi"><xsl:with-param name="n" select="4"/></xsl:call-template>
 
=={{header|XQuery}}==
Line 5,368 ⟶ 5,341:
</move>
</hanoi></lang>
 
=={{header|XSLT}}==
<lang xml><xsl:template name="hanoi">
<xsl:param name="n"/>
<xsl:param name="from">left</xsl:param>
<xsl:param name="to">middle</xsl:param>
<xsl:param name="via">right</xsl:param>
<xsl:if test="$n &gt; 0">
<xsl:call-template name="hanoi">
<xsl:with-param name="n" select="$n - 1"/>
<xsl:with-param name="from" select="$from"/>
<xsl:with-param name="to" select="$via"/>
<xsl:with-param name="via" select="$to"/>
</xsl:call-template>
<fo:block>
<xsl:text>Move disk from </xsl:text>
<xsl:value-of select="$from"/>
<xsl:text> to </xsl:text>
<xsl:value-of select="$to"/>
</fo:block>
<xsl:call-template name="hanoi">
<xsl:with-param name="n" select="$n - 1"/>
<xsl:with-param name="from" select="$via"/>
<xsl:with-param name="to" select="$to"/>
<xsl:with-param name="via" select="$from"/>
</xsl:call-template>
</xsl:if>
</xsl:template></lang>
 
<xsl:call-template name="hanoi"><xsl:with-param name="n" select="4"/></xsl:call-template>
 
=={{header|Yabasic}}==
10,333

edits