মডিউল:TableTools: সংশোধিত সংস্করণের মধ্যে পার্থক্য

don't sort union and intersection functions
use a hack to handle NaN values
১৪ নং লাইন: ১৪ নং লাইন:
local floor = math.floor
local floor = math.floor
local infinity = math.huge
local infinity = math.huge
-- Define a unique value to represent NaN. This is because NaN cannot be used as a table key.
local nan = {}


--[[
--[[
৪৭ নং লাইন: ৫০ নং লাইন:
for _, t in ipairs(tables) do
for _, t in ipairs(tables) do
for k, v in pairs(t) do
for k, v in pairs(t) do
if type(v) == 'number' and tostring(v) == '-nan' then
v = nan -- NaN cannot be a table key, so use a proxy variable.
end
vals[v] = true
vals[v] = true
end
end
end
end
for val in pairs(vals) do
for val in pairs(vals) do
if val == nan then
-- This ensures that we output a NaN when we had one as input, although
-- they may have been generated in a completely different way.
val = 0/0
end
ret[#ret + 1] = val
ret[#ret + 1] = val
end
end
৭১ নং লাইন: ৮২ নং লাইন:
for _, t in ipairs(tables) do
for _, t in ipairs(tables) do
for k, v in pairs(t) do
for k, v in pairs(t) do
if type(v) == 'number' and tostring(v) == '-nan' then
v = nan -- NaN cannot be a table key, so use a proxy variable.
end
local valCount = vals[v] or 0
local valCount = vals[v] or 0
vals[v] = valCount + 1
vals[v] = valCount + 1
৭৭ নং লাইন: ৯১ নং লাইন:
for val, count in pairs(vals) do
for val, count in pairs(vals) do
if count == lim then
if count == lim then
if val == nan then
-- This ensures that we output a NaN when we had one as input, although
-- they may have been generated in a completely different way.
val = 0/0
end
ret[#ret + 1] = val
ret[#ret + 1] = val
end
end