Lua ![]() |
http://www.tecgraf.puc-rio.br/lua/ |
Beschreibung: | "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 (similar to Pascal) with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, interpreted from bytecodes, and has automatic memory management, making it ideal for configuration, scripting, and rapid prototyping." Lua has a very small footprint and let's itself very easy embed into other languages. |
Fakultät | Michael Neumann |
function fac(n) if n < 2 then return 1 else return n * fac(n-1) end end print(fac(6)) |
Berechnet die Fakultät. Ergibt
720 . |
Hello World | Michael Neumann |
-- Hello World in Lua print("Hello World\n") |
Gibt "Hello World" auf dem Bildschirm
aus. |
Squares (1) | Michael Neumann |
-- for var = from, to [, step] do block end for i = 1, 10, 1 do print(i*i) end |
Gibt die Quadrate von 1 bis 10
aus. |
Squares (2) | Michael Neumann |
function range(from, to) arr, inx = {}, 0 for i = from, to do arr[inx] = i inx = inx + 1 end return arr end for index, value in range(1, 10) do print(index .. "^2 = " .. value) end |
Gibt die Quadrate von 1 bis 10
aus. |