Renamed file and minor cleanup.

This commit is contained in:
Marcos Kirsch 2015-02-08 22:08:18 -06:00
parent a8d408f375
commit 3e452992c8
2 changed files with 2 additions and 32 deletions

View File

@ -1,9 +1,9 @@
-- Print anything - including nested tables -- Print anything - including nested tables
-- Based on but modified from: -- Based on but modified from:
-- http://lua-users.org/wiki/TableSerialization -- http://lua-users.org/wiki/TableSerialization
module("printTable", package.seeall) module("TablePrinter", package.seeall)
function printTable.printTable (tt, indent, done) function TablePrinter.print (tt, indent, done)
done = done or {} done = done or {}
indent = indent or 0 indent = indent or 0
if tt == nil then if tt == nil then

View File

@ -1,30 +0,0 @@
-- Print anything - including nested tables
-- Based on but modified from:
-- http://lua-users.org/wiki/TableSerialization
function printTable (tt, indent, done)
done = done or {}
indent = indent or 0
if tt == nil then
io.write("nil\n")
else
if type(tt) == "table" then
for key, value in pairs (tt) do
io.write(string.rep (" ", indent)) -- indent it
if type (value) == "table" and not done [value] then
done [value] = true
io.write(string.format("[%s] => table\n", tostring (key)));
io.write(string.rep (" ", indent+4)) -- indent it
io.write("(\n");
table_print (value, indent + 7, done)
io.write(string.rep (" ", indent+4)) -- indent it
io.write(")\n");
else
io.write(string.format("[%s] => %s\n",
tostring (key), tostring(value)))
end
end
else
io.write(tt .. "\n")
end
end
end