Towers of Hanoi: Difference between revisions
Content added Content deleted
m (→[[Toka]]: minor cleanup using new way of declaring variables) |
(Added Forth example (from comp.lang.forth)) |
||
Line 67: | Line 67: | ||
move(stdout, 4, def left {}, def right {}, def middle {}) |
move(stdout, 4, def left {}, def right {}, def middle {}) |
||
==[[Forth]]== |
|||
[[Category:Forth]] |
|||
CREATE peg1 ," left " |
|||
CREATE peg2 ," middle " |
|||
CREATE peg3 ," right " |
|||
: MOVE-DISK |
|||
LOCALS| via to from n | |
|||
n 1 = IF CR ." Move disk from " from .$ ." to " to .$ |
|||
ELSE n 1- from via to RECURSE |
|||
1 from to via RECURSE |
|||
n 1- via to from RECURSE |
|||
ENDIF ; |
|||
==[[Java]]== |
==[[Java]]== |