此模块的文档可以在模块:Util/doc创建

local p = {}

function p.map(list, func)
	local new_list = {}
	for i,v in ipairs(list) do
		new_list[i] = func(v)
	end
	return new_list
end

function p.filter(list, func)
	local new_list = {}
	for _,v in ipairs(list) do
		if func(v) then
			table.insert(new_list, v)
		end
	end
	return new_list
end

function p.clone(t)
	local new_t = {}
	for k,v in pairs(t) do
		new_t[k] = v
	end
	return new_t
end

return p
0.0
0人评价
avatar