Módulo:Tablas
La documentación para este módulo puede ser creada en Módulo:Tablas/doc
local z = {}
function z.tostring(tabla, identacion)
identacion = identacion or '\n'
local resultado = ''
for k,v in pairs(tabla) do
if type(k) == 'string' then
k2='"' .. k .. '"'
else
k2=k
end
if type(v)=='table' then
resultado = resultado .. identacion .. k2 .. ': {' .. z.tostring(v,identacion .. ' ') .. identacion .. '}'
elseif type(v)=='string' then
resultado = resultado .. identacion .. k2 .. ': "' .. v .. '"'
else
resultado = resultado .. identacion .. k2 .. ': ' .. tostring(v)
end
end
return resultado
end
function z.en(tabla, elemento)
if not elemento then
return
end
for k,v in pairs( tabla ) do
if v == elemento then
return k
end
end
end
return z