lua-users home
lua-l archive

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



function table.compare(t1,t2)
if table.len(t1)~=table.len(t2) then return false; end
table.foreach(t1,
function(k,v)
if v~=t2[k] and type(v)~='table' then
return false;
elseif v~=t2[k] then
return table.compare(v,t2[k])
end
end
)
return true;
end

You have two table traversals here, that kind of defeats the table.len() check purpose.

Also please note that table.foreach() is deprecated.

Alexander.