Loops
See integer loops docs
for var=exp1,exp2,exp3 do
something
end
-- find a value in a list
local found = nil
for i=1,a.n do
if a[i] == value then
found = i -- save value of `i'
break
end
end
print(found)
Functions As Variables
function a(x)
print(x)
end
function b(x)
print(x..x)
end
-- functions can be passed as variables
function comb(f,g)
f("world")
g("flibble")
end
a("hello1")
b("hello2")
comb(a,b)
--[[
outputs
hello
hellohello
world
flibbleflibble
--]]
Integer String Conversion
tostring(42)
tonumber("42")
String formatting
a = string.format("%03d",42)