Changes
Jump to navigation
Jump to search
-- Define a unique value to represent NaN. This is because NaN cannot be used as a table key.
local nan = {}
vals[v] = true
end
end
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
ret[#ret + 1] = val
fix the valueUnion function for NaNs (and make it a lot simpler to boot)
local infinity = math.huge
local checkType = libraryUtil.checkType
--[[
function p.valueUnion(...)
local lim = select('#', ...)
if lim == 0 < 2 then error(lim .. ' argument' .. (lim == 1 and '' or 's') .. "no arguments passed to 'valueUnion'(minimum is 2)", 2)
end
local valsisNan = p.isNan local ret, ret exists = {}, {}
for i = 1, lim do
local t = select(i, ...)
checkType('valueUnion', i, t, 'table')
for k, v in pairs(t) do
if typeisNan(v) then ret[#ret + 1] =v elseif not exists[v] then ret[#ret + 1] = 'number' and tostring(v) == '-nan' then exists[v ] = nan -- NaN cannot be a table key, so use a proxy variable.true
end
end
end
return ret