Anonymous

Module:Shared: Difference between revisions

From Melvor Idle
first attempt at p.tablesEqual
(Added shortened timestring version)
(first attempt at p.tablesEqual)
(2 intermediate revisions by the same user not shown)
Line 178: Line 178:
   
   
         if(maxDigits ~= nil and decimals > maxDigits) then
         if(maxDigits ~= nil and decimals > maxDigits) then
             result = tonumber(string.format("%."..maxDigits.."f", result))
             result = string.format("%."..minDigits.."f", tonumber(string.format("%."..maxDigits.."f", result)))
         elseif(minDigits ~= nil and decimals < minDigits) then
         elseif(minDigits ~= nil and decimals < minDigits) then
             result = string.format("%."..minDigits.."f", result)
             result = string.format("%."..minDigits.."f", result)
Line 348: Line 348:
   return table.concat(pieces, ', ')
   return table.concat(pieces, ', ')
end
end
 
function p.fixPagename(pageName)
  local result = pageName
  result = string.gsub(result, "%%27", "'")
  result = string.gsub(result, "&#39;", "'")
  return result
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