Module:Shared: Difference between revisions

first attempt at p.tablesEqual
(Fixed specific edge case of rounding sometimes leading to too few digits being shown.)
(first attempt at p.tablesEqual)
Line 355: Line 355:
   return result
   return result
end
end
 
function p.tablesEqual(t1, t2)
  if p.tableCount(t1) ~= p.tableCount(t2) then return false end
  for i, val in p.skpairs(t1) do
    if type(val) ~= type(t2[i]) then
      return false
    elseif type(val) == 'table' then
      if not p.tablesEqual(val, t2[i]) then return false end
    elseif t2[i] ~= val then
      return false
    end
  end
  return true
end
 
return p
return p