Module:Sandbox/iantresman/sandbox/archive/mw.recursive: Difference between revisions
imported>Iantresman ←Created page with 'local p = {} -- defines a variable p as an empty table, but *not* nil. local a = {} a.b = {} a.b.c = {} a.b.c.d = {} a.b.c.d.e = "some string" a.b.c.f = "some o...' |
(No difference)
|
Latest revision as of 23:02, 11 December 2013
Documentation for this module may be created at Module:Sandbox/iantresman/sandbox/archive/mw.recursive/doc
local p = {} -- defines a variable p as an empty table, but *not* nil.
local a = {}
a.b = {}
a.b.c = {}
a.b.c.d = {}
a.b.c.d.e = "some string"
a.b.c.f = "some other string"
function p.main( frame )
result = "*LUA Version: " .. _VERSION
-- result = result .. "\n*Arguments: " .. prtable(frame.args)
-- result = result .. "\n*MW data: " .. prtable(mw.site)
result = result .. "\n*Example table: " .. prtable(a)
return result
end
function prtable(t, result)
result = result or ""
if type(t) == "table" then
for k, v in pairs(t) do
if type(v)=="string" then
result = result .. "\n:" .. k .. ": " .. v
else
result = result .. "\n:" .. k .. ": " .. prtable(v, result)
end
end
else
result = result .. tostring(t)
end
return result
end
return p