[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Recursive Traversal of Tables
- From: Bret Victor <bret@...>
- Date: Sun, 28 May 2006 08:06:49 +0000 (UTC)
But if you do, in fact, need your parameters to be traversed in
order, and that order is consistent throughout, this will work:
-- Specify order for parameters.
local paramNames = "name server IP domain class license JDK " ..
"WebLogicVersion Console instance port"
function Project (table)
-- Traverse string keys in order. Values are parameters.
for k in string.gmatch(paramNames, "%S+") do
if table[k] then print(k,table[k]) end
end
-- Traverse number keys. Values are subtables.
for i,v in ipairs(table) do
Project(v)
end
end
-Bret