AppleScript
The Towers of Hanoi as an AppleScript program.
AppleScript is an English-like language used (on Apple Computers) to write script files which can automate the actions of the computer and the applications which run on it.
For more information on AppleScript, please visit the AppleScript home page.
-- The Towers Of Hanoi
-- AppleScript
-- Copyright (C) 2003 Amit Singh. All Rights Reserved.
-- http://hanoi.kernelthread.com
--
-- Tested on Mac OS X 10.2.4
--
on doHanoi(n, f, u, t)
if n <= 1 then
log f & " --> " & t
else
doHanoi(n - 1, f, t, u)
log f & " --> " & t
doHanoi(n - 1, u, f, t)
end if
end doHanoi
on hanoi(n)
if n < 0 or n > 10 then
log "usage: hanoi(n) where 1 <= n <= 10"
else
doHanoi(n, 1, 2, 3)
end if
end hanoi
hanoi(3)