Changes
		
		
		
		
		
		
		Jump to navigation
		Jump to search
		
		
		
		
		
		
		
		
	
add a key/value pair intersection function
------------------------------------------------------------------------------------
--]]
function p.intersection(...)
	local differentVals = {} -- A substitute variable to use when we have different values for the same key.
	local ret, track, pairCounts = {}, {}, {}
	local lim = select('#', ...)
	for i = 1, lim do
		local t = select(i, ...)
		for k, v in pairs(t) do
			local trackVal = track[k]
			if trackVal == nil then
				track[k] = v
				pairCounts[k] = 1
			elseif trackVal == v then
				pairCounts[k] = pairCounts[k] + 1
			end
		end
	end
	for k, v in pairs(track) do
		if pairCounts[k] == lim then
			ret[k] = v
		end
	end
	return ret
end
--[[