local function T(T)return function(x,h)if x==nil then x={}end local y={}for T,Q in pairs(T)do y[T]=Q(x[T],h)end return y end end return T

local function combineReducers(map)
	return function(state, action)
		-- If state is nil, substitute it with a blank table.
		if state == nil then
			state = {}
		end

		local newState = {}

		for key, reducer in pairs(map) do
			-- Each reducer gets its own state, not the entire state table
			newState[key] = reducer(state[key], action)
		end

		return newState
	end
end

return combineReducers
