lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Try this code:

table.foreach(t, print)

This table.foreach is a function to map algorithm (see

Perhaps, you can write this:

function inspect(key, value)
  local prefix = name
  local out = prefix and prefix..".%s" or "%s"
  if type(value) == "table" then
    name = prefix.."."..key
    table.foreach(value, inspect)
    name = prefix
    out = type(value) == "function" and out.."()" or out.." = %s"
    print(out:format(key, tostring(value)))

name = "t"
table.foreach(t, inspect)

Don't run this code using the _G table. The C stack overflow is
throwed because _G has a reference to yourself.


On Fri, May 4, 2012 at 1:22 PM, Petite Abeille <> wrote:
> On May 4, 2012, at 7:15 PM, Emeka wrote:
>> I would want to use a print-like function to do the following:

Hallison Batista