kernelthread.com

Lua

The Towers of Hanoi as a Lua program.

According to the Lua website:

Lua is a powerful light-weight programming language designed for extending applications. Lua is also frequently used as a general-purpose, stand-alone language. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, interpreted from bytecodes, and has automatic memory management with garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

-- The Towers Of Hanoi -- Lua -- Copyright (C) 2002 Amit Singh. All Rights Reserved. -- http://hanoi.kernelthread.com -- -- Last tested under Lua 5.0 beta -- http://www.lua.org -- function H(n, f, u, t) if n < 2 then print(f, " --> ", t) else H(n - 1, f, t, u) print(f, " --> ", t) H(n - 1, u, f, t) end end function hanoi(n) if n > 0 and n <= 10 then H(n, 1, 2, 3) else print("usage: hanoi n, where 0 < n <= 10") end end hanoi(3)

Download

hanoi.lua