触感是什么意思| 旺字五行属什么| 眼睛充血是什么原因造成的| 卵巢早衰是什么引起的| 百思不得其解什么意思| 喝什么水好啊| 杭州都有什么区| 考试前吃什么好| 脾大吃什么药能缩小| 悲戚是什么意思| 血小板为什么会高| 智齿疼吃什么药| 花生属于什么类食物| 颈部淋巴结肿大是什么原因| 热伤风感冒吃什么药好| 上海话娘娘是什么意思| 细菌性感冒吃什么药效果好| cd ts 什么意思| 你是我的唯一什么意思| 齁是什么意思| 左手小手指麻木是什么原因引起的| 腊月初四是什么星座| 蜜糖有什么功效和作用| 低血压低是什么原因| 千克又叫什么| 什么充电宝可以带上飞机| 大便粘稠吃什么药| 当志愿者有什么好处| 2022年属虎的是什么命| 造势是什么意思| 飞吻是什么意思| 什么奶粉最好| 梦见蟒蛇是什么预兆| 坚果什么时候吃最好| 高血糖能吃什么水果| 衣原体阳性是什么意思| 感激涕零什么意思| 6.15是什么日子| 胃炎吃什么最好| 软组织是什么| 兔肉不能和什么一起吃| 狗男和什么属相最配| 卸妆用什么最好| 2024是什么年| 梦到买房子是什么意思| 碱是什么东西| 办护照需要什么证件| 骨头受伤了吃什么恢复的快| 城镇户口是什么意思| 胆结石有什么症状| 为什么黄瓜是绿色的却叫黄瓜| 支气管疾患是什么意思| 心肌酶谱是查什么的| 涂防晒霜之前要涂什么| 舌苔厚白用什么泡水喝| rh是什么单位| 福生无量是什么意思| 心肌供血不足是什么原因造成的| 午夜是什么时候| 放化疗后吃什么恢复快| 5月6号是什么星座| 宝宝乳糖不耐受喝什么奶粉比较好| 什么是民间故事| 地球属于什么星| 痛风能吃什么水果| 为什么会闰月| 逃之夭夭是什么意思| 血糖高适合吃什么主食| 省政协委员是什么级别| 儿童头痛挂什么科| 手指头痒是什么原因| 怀孕有什么特征和反应| 女人吃火龙果有什么好处| 什么是远视| 属猴的和什么属相最配| 闪购是什么| 什么是星座| 共济失调是什么病| 什么是白领| 做宫腔镜检查需要提前做什么准备| 是什么梗| 总放屁是什么病的前兆| 下午3点是什么时辰| 女人更年期是什么症状| 尼泊尔人是什么人种| 漂白粉是什么| 9.20号是什么星座| 退化是什么意思| 下限是什么意思| 离婚都需要什么手续和证件| 放疗有什么危害| 肋骨下面疼是什么原因| 全麦面包是什么意思| pt950是什么意思| 幽门螺旋杆菌弱阳性是什么意思| 先自度其足的度是什么意思| 梦见自己打胎是什么意思| 奇点是什么意思| 牙龈发炎用什么药| 咳嗽有痰吃什么药效果好| 右额头上有痣代表什么| 药剂师是干什么的| 放任是什么意思| 女人左眼下有痣代表什么| 什么是五毒| 什么牌子的氨糖好| 穿刺是检查什么的| 蛋白肉是什么东西做的| 慢性非萎缩性胃炎什么意思| 9月27日是什么星座| 疑难杂症是什么意思| 乳酸是什么东西| 什么是物理学| 备孕吃什么最容易怀孕| 香港代购什么东西好| 胃疼想吐是什么原因| 什么是食品添加剂| 前列腺液是什么| 宫腔镜是什么| 羊水暗区是什么意思| 我是什么课文| 胸口不舒服是什么原因| 龙的五行属性是什么| 公斤的单位是什么| 什么是熊猫血型| 什么叫宫腔粘连| 做梦梦到自己拉屎是什么意思| 孕妇适合吃什么零食| 老是拉肚子是什么原因| haccp认证是什么意思| pfs是什么意思| 吃什么降胆固醇最快| 阴虱用什么药| 天后是什么意思| 右侧后背疼是什么原因| 送什么生日礼物给妈妈| 面筋是什么| 弱冠是什么意思| 手足口病忌口什么食物| 为什么会长汗斑| 1965属什么生肖| 属虎的守护神是什么菩萨| 青霉素v钾片治什么病| 化验血挂什么科| 黄体破裂是什么原因造成的| 老白茶属于什么茶| 咽喉有异物感吃什么药| 血压高什么不能吃| nike是什么牌子| plg是什么意思| 桑蚕丝被有什么好处| 途字五行属什么| 喝茶是什么意思| 胆囊壁胆固醇结晶是什么意思| 母亲节要送什么礼物| 西湖醋鱼是什么菜系| c表示什么| 月子中心需要什么资质| 茶化石属于什么茶| 完蛋是什么意思| 单位工会主席是什么级别| molly是什么意思| 威海有什么好玩的| 阴囊两侧瘙痒是什么原因| 吃什么补骨髓造血| 开飞机什么意思| 96属什么生肖| 做什么饭简单又好吃| 晚生是什么意思| 扒拉是什么意思| gmp是什么| 绿豆有什么功效| 花开花落不见你回头是什么歌| 蝴蝶有什么寓意| 爱的真正含义是什么| 小孩多动症是什么原因引起的| 网球大满贯什么意思| 冰菜是什么菜| 怀男孩和女孩有什么区别| 李世民属什么生肖| 鼻子发痒是什么原因引起的| 柠檬水苦是什么原因| 小排畸主要检查什么| 草朋刀是什么字| 耳朵痒痒是什么原因| 79岁属什么| 吃什么补铁| 岔气是什么意思| 护士规培是什么意思| 林冲为什么叫豹子头| 肉苁蓉和什么搭配最好| 洗牙挂什么科| 肋骨骨折挂什么科| exo的e为什么不发音| 夫妻合葬有什么讲究| 子宫内膜薄是什么原因造成的| 喉咙不舒服是什么原因| 女性更年期在什么年龄段| 低热是什么症状| 摩羯座和什么星座最配| 鼻窦炎是什么病| 胆汁酸高是什么意思| 啄木鸟吃什么食物| 水泥烧伤皮肤用什么药| 个子矮穿什么好看| 反流性食管炎吃什么中成药| 驻村是什么意思| 什么的粉墙| 称谓是什么意思| qc是什么| 检查前列腺需要做什么检查| 什么时候验孕最准确| 荨麻疹忌口忌什么食物| 黄疸有什么症状| 女强人是什么意思| 什么雅| 痛风是什么意思| 手臂有痣代表什么| 陈皮是什么水果的皮| 女人的胸长什么样| 什么的眼泪| 全身皮肤痒是什么原因| 抗皱用什么产品好| 冲太岁什么意思| 乘务员是干什么的| 绵密是什么意思| 吃什么东西越吃越饿| 多囊卵巢是什么意思| 吃什么补气最快| 拉条子是什么意思| 盐的主要成分是什么| 四月份什么星座| 糊精是什么东西| 升血压吃什么药| 狗喜欢吃什么食物| 孕妇子痫是什么病| bra是什么| 六月二十一是什么日子| 01年是什么年| 梦见摘瓜是什么意思啊| 指甲长出来是白色的什么原因| 夏令时什么意思| 小子是什么意思| 甲亢吃什么| 安全期是什么| 厨子什么意思| 阿尔兹海默症是什么病| 遣返是什么意思| 什么叫眼睛散光| 无下限是什么意思| 紫癜是一种什么病| 拉格啤酒是什么意思| 临盆是什么意思| 身体出现白斑有可能患什么病| 干燥综合症是什么病| wonderful什么意思| 痉挛是什么| 哥斯拉是什么动物| 男人第一次什么 感觉| 酪朊酸钠是什么| 什么东西掉进水里不会湿| 小燕子吃什么| 霉菌性阴道炎是什么症状| 君无戏言什么意思| 百度Jump to content

礼仪是什么

Fi Wikipedia
百度 从个人角度来看,我从小就在佛罗里达长大,而且每个夏天都会来奥兰多打球。

Documentation for this module may be created at Module:TableTools/doc

------------------------------------------------------------------------------------
--                                   TableTools                                   --
--                                                                                --
-- This module includes a number of functions for dealing with Lua tables.        --
-- It is a meta-module, meant to be called from other Lua modules, and should not --
-- be called directly from #invoke.                                               --
------------------------------------------------------------------------------------

local libraryUtil = require('libraryUtil')

local p = {}

-- Define often-used variables and functions.
local floor = math.floor
local infinity = math.huge
local checkType = libraryUtil.checkType
local checkTypeMulti = libraryUtil.checkTypeMulti

------------------------------------------------------------------------------------
-- isPositiveInteger
--
-- This function returns true if the given value is a positive integer, and false
-- if not. Although it doesn't operate on tables, it is included here as it is
-- useful for determining whether a given table key is in the array part or the
-- hash part of a table.
------------------------------------------------------------------------------------
function p.isPositiveInteger(v)
	return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity
end

------------------------------------------------------------------------------------
-- isNan
--
-- This function returns true if the given number is a NaN value, and false if
-- not. Although it doesn't operate on tables, it is included here as it is useful
-- for determining whether a value can be a valid table key. Lua will generate an
-- error if a NaN is used as a table key.
------------------------------------------------------------------------------------
function p.isNan(v)
	return type(v) == 'number' and v ~= v
end

------------------------------------------------------------------------------------
-- shallowClone
--
-- This returns a clone of a table. The value returned is a new table, but all
-- subtables and functions are shared. Metamethods are respected, but the returned
-- table will have no metatable of its own.
------------------------------------------------------------------------------------
function p.shallowClone(t)
	checkType('shallowClone', 1, t, 'table')
	local ret = {}
	for k, v in pairs(t) do
		ret[k] = v
	end
	return ret
end

------------------------------------------------------------------------------------
-- removeDuplicates
--
-- This removes duplicate values from an array. Non-positive-integer keys are
-- ignored. The earliest value is kept, and all subsequent duplicate values are
-- removed, but otherwise the array order is unchanged.
------------------------------------------------------------------------------------
function p.removeDuplicates(arr)
	checkType('removeDuplicates', 1, arr, 'table')
	local isNan = p.isNan
	local ret, exists = {}, {}
	for _, v in ipairs(arr) do
		if isNan(v) then
			-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.
			ret[#ret + 1] = v
		elseif not exists[v] then
			ret[#ret + 1] = v
			exists[v] = true
		end
	end
	return ret
end

------------------------------------------------------------------------------------
-- numKeys
--
-- This takes a table and returns an array containing the numbers of any numerical
-- keys that have non-nil values, sorted in numerical order.
------------------------------------------------------------------------------------
function p.numKeys(t)
	checkType('numKeys', 1, t, 'table')
	local isPositiveInteger = p.isPositiveInteger
	local nums = {}
	for k in pairs(t) do
		if isPositiveInteger(k) then
			nums[#nums + 1] = k
		end
	end
	table.sort(nums)
	return nums
end

------------------------------------------------------------------------------------
-- affixNums
--
-- This takes a table and returns an array containing the numbers of keys with the
-- specified prefix and suffix. For example, for the table
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will return
-- {1, 3, 6}.
------------------------------------------------------------------------------------
function p.affixNums(t, prefix, suffix)
	checkType('affixNums', 1, t, 'table')
	checkType('affixNums', 2, prefix, 'string', true)
	checkType('affixNums', 3, suffix, 'string', true)

	local function cleanPattern(s)
		-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.
		return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')
	end

	prefix = prefix or ''
	suffix = suffix or ''
	prefix = cleanPattern(prefix)
	suffix = cleanPattern(suffix)
	local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'

	local nums = {}
	for k in pairs(t) do
		if type(k) == 'string' then
			local num = mw.ustring.match(k, pattern)
			if num then
				nums[#nums + 1] = tonumber(num)
			end
		end
	end
	table.sort(nums)
	return nums
end

------------------------------------------------------------------------------------
-- numData
--
-- Given a table with keys like {"foo1", "bar1", "foo2", "baz2"}, returns a table
-- of subtables in the format
-- {[1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'}}.
-- Keys that don't end with an integer are stored in a subtable named "other". The
-- compress option compresses the table so that it can be iterated over with
-- ipairs.
------------------------------------------------------------------------------------
function p.numData(t, compress)
	checkType('numData', 1, t, 'table')
	checkType('numData', 2, compress, 'boolean', true)
	local ret = {}
	for k, v in pairs(t) do
		local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')
		if num then
			num = tonumber(num)
			local subtable = ret[num] or {}
			if prefix == '' then
				-- Positional parameters match the blank string; put them at the start of the subtable instead.
				prefix = 1
			end
			subtable[prefix] = v
			ret[num] = subtable
		else
			local subtable = ret.other or {}
			subtable[k] = v
			ret.other = subtable
		end
	end
	if compress then
		local other = ret.other
		ret = p.compressSparseArray(ret)
		ret.other = other
	end
	return ret
end

------------------------------------------------------------------------------------
-- compressSparseArray
--
-- This takes an array with one or more nil values, and removes the nil values
-- while preserving the order, so that the array can be safely traversed with
-- ipairs.
------------------------------------------------------------------------------------
function p.compressSparseArray(t)
	checkType('compressSparseArray', 1, t, 'table')
	local ret = {}
	local nums = p.numKeys(t)
	for _, num in ipairs(nums) do
		ret[#ret + 1] = t[num]
	end
	return ret
end

------------------------------------------------------------------------------------
-- sparseIpairs
--
-- This is an iterator for sparse arrays. It can be used like ipairs, but can
-- handle nil values.
------------------------------------------------------------------------------------
function p.sparseIpairs(t)
	checkType('sparseIpairs', 1, t, 'table')
	local nums = p.numKeys(t)
	local i = 0
	local lim = #nums
	return function ()
		i = i + 1
		if i <= lim then
			local key = nums[i]
			return key, t[key]
		else
			return nil, nil
		end
	end
end

------------------------------------------------------------------------------------
-- size
--
-- This returns the size of a key/value pair table. It will also work on arrays,
-- but for arrays it is more efficient to use the # operator.
------------------------------------------------------------------------------------
function p.size(t)
	checkType('size', 1, t, 'table')
	local i = 0
	for _ in pairs(t) do
		i = i + 1
	end
	return i
end

local function defaultKeySort(item1, item2)
	-- "number" < "string", so numbers will be sorted before strings.
	local type1, type2 = type(item1), type(item2)
	if type1 ~= type2 then
		return type1 < type2
	elseif type1 == 'table' or type1 == 'boolean' or type1 == 'function' then
		return tostring(item1) < tostring(item2)
	else
		return item1 < item2
	end
end
------------------------------------------------------------------------------------
-- keysToList
--
-- Returns an array of the keys in a table, sorted using either a default
-- comparison function or a custom keySort function.
------------------------------------------------------------------------------------
function p.keysToList(t, keySort, checked)
	if not checked then
		checkType('keysToList', 1, t, 'table')
		checkTypeMulti('keysToList', 2, keySort, {'function', 'boolean', 'nil'})
	end

	local arr = {}
	local index = 1
	for k in pairs(t) do
		arr[index] = k
		index = index + 1
	end

	if keySort ~= false then
		keySort = type(keySort) == 'function' and keySort or defaultKeySort
		table.sort(arr, keySort)
	end

	return arr
end

------------------------------------------------------------------------------------
-- sortedPairs
--
-- Iterates through a table, with the keys sorted using the keysToList function.
-- If there are only numerical keys, sparseIpairs is probably more efficient.
------------------------------------------------------------------------------------
function p.sortedPairs(t, keySort)
	checkType('sortedPairs', 1, t, 'table')
	checkType('sortedPairs', 2, keySort, 'function', true)

	local arr = p.keysToList(t, keySort, true)

	local i = 0
	return function ()
		i = i + 1
		local key = arr[i]
		if key ~= nil then
			return key, t[key]
		else
			return nil, nil
		end
	end
end

------------------------------------------------------------------------------------
-- isArray
--
-- Returns true if the given value is a table and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArray(v)
	if type(v) ~= 'table' then
		return false
	end
	local i = 0
	for _ in pairs(v) do
		i = i + 1
		if v[i] == nil then
			return false
		end
	end
	return true
end

------------------------------------------------------------------------------------
-- isArrayLike
--
-- Returns true if the given value is iterable and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArrayLike(v)
	if not pcall(pairs, v) then
		return false
	end
	local i = 0
	for _ in pairs(v) do
		i = i + 1
		if v[i] == nil then
			return false
		end
	end
	return true
end

------------------------------------------------------------------------------------
-- invert
--
-- Transposes the keys and values in an array. For example, {"a", "b", "c"} ->
-- {a = 1, b = 2, c = 3}. Duplicates are not supported (result values refer to
-- the index of the last duplicate) and NaN values are ignored.
------------------------------------------------------------------------------------
function p.invert(arr)
	checkType("invert", 1, arr, "table")
	local isNan = p.isNan
	local map = {}
	for i, v in ipairs(arr) do
		if not isNan(v) then
			map[v] = i
		end
	end

	return map
end

------------------------------------------------------------------------------------
-- listToSet
--
-- Creates a set from the array part of the table. Indexing the set by any of the
-- values of the array returns true. For example, {"a", "b", "c"} ->
-- {a = true, b = true, c = true}. NaN values are ignored as Lua considers them
-- never equal to any value (including other NaNs or even themselves).
------------------------------------------------------------------------------------
function p.listToSet(arr)
	checkType("listToSet", 1, arr, "table")
	local isNan = p.isNan
	local set = {}
	for _, v in ipairs(arr) do
		if not isNan(v) then
			set[v] = true
		end
	end

	return set
end

------------------------------------------------------------------------------------
-- deepCopy
--
-- Recursive deep copy function. Preserves identities of subtables.
------------------------------------------------------------------------------------
local function _deepCopy(orig, includeMetatable, already_seen)
	if type(orig) ~= "table" then
		return orig
	end
	
	-- already_seen stores copies of tables indexed by the original table.
	local copy = already_seen[orig]
	if copy ~= nil then
		return copy
	end
	
	copy = {}
	already_seen[orig] = copy -- memoize before any recursion, to avoid infinite loops
	
	for orig_key, orig_value in pairs(orig) do
		copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen)
	end
	
	if includeMetatable then
		local mt = getmetatable(orig)
		if mt ~= nil then
			setmetatable(copy, _deepCopy(mt, true, already_seen))
		end
	end
	
	return copy
end

function p.deepCopy(orig, noMetatable, already_seen)
	checkType("deepCopy", 3, already_seen, "table", true)
	return _deepCopy(orig, not noMetatable, already_seen or {})
end

------------------------------------------------------------------------------------
-- sparseConcat
--
-- Concatenates all values in the table that are indexed by a number, in order.
-- sparseConcat{a, nil, c, d}  =>  "acd"
-- sparseConcat{nil, b, c, d}  =>  "bcd"
------------------------------------------------------------------------------------
function p.sparseConcat(t, sep, i, j)
	local arr = {}

	local arr_i = 0
	for _, v in p.sparseIpairs(t) do
		arr_i = arr_i + 1
		arr[arr_i] = v
	end

	return table.concat(arr, sep, i, j)
end

------------------------------------------------------------------------------------
-- length
--
-- Finds the length of an array, or of a quasi-array with keys such as "data1",
-- "data2", etc., using an exponential search algorithm. It is similar to the
-- operator #, but may return a different value when there are gaps in the array
-- portion of the table. Intended to be used on data loaded with mw.loadData. For
-- other tables, use #.
-- Note: #frame.args in frame object always be set to 0, regardless of  the number
-- of unnamed template parameters, so use this function for frame.args.
------------------------------------------------------------------------------------
function p.length(t, prefix)
	-- requiring module inline so that [[Module:Exponential search]] which is
	-- only needed by this one function doesn't get millions of transclusions
	local expSearch = require("Module:Exponential search")
	checkType('length', 1, t, 'table')
	checkType('length', 2, prefix, 'string', true)
	return expSearch(function (i)
		local key
		if prefix then
			key = prefix .. tostring(i)
		else
			key = i
		end
		return t[key] ~= nil
	end) or 0
end

------------------------------------------------------------------------------------
-- inArray
--
-- Returns true if searchElement is a member of the array, and false otherwise.
-- Equivalent to JavaScript array.includes(searchElement) or
-- array.includes(searchElement, fromIndex), except fromIndex is 1 indexed
------------------------------------------------------------------------------------
function p.inArray(array, searchElement, fromIndex)
	checkType("inArray", 1, array, "table")
	-- if searchElement is nil, error?

	fromIndex = tonumber(fromIndex)
	if fromIndex then
		if (fromIndex < 0) then
			fromIndex = #array + fromIndex + 1
		end
		if fromIndex < 1 then fromIndex = 1 end
		for _, v in ipairs({unpack(array, fromIndex)}) do
			if v == searchElement then
				return true
			end
		end
	else
		for _, v in pairs(array) do
			if v == searchElement then
				return true
			end
		end
	end
	return false
end

------------------------------------------------------------------------------------
-- merge
--
-- Given the arrays, returns an array containing the elements of each input array
-- in sequence.
------------------------------------------------------------------------------------
function p.merge(...)
	local arrays = {...}
	local ret = {}
	for i, arr in ipairs(arrays) do
		checkType('merge', i, arr, 'table')
		for _, v in ipairs(arr) do
			ret[#ret + 1] = v
		end
	end
	return ret
end

------------------------------------------------------------------------------------
-- extend
--
-- Extends the first array in place by appending all elements from the second
-- array.
------------------------------------------------------------------------------------
function p.extend(arr1, arr2)
	checkType('extend', 1, arr1, 'table')
	checkType('extend', 2, arr2, 'table')

	for _, v in ipairs(arr2) do
		arr1[#arr1 + 1] = v
	end
end

return p
意大利面是用什么做的 pony是什么意思 转氨酶高吃什么药效果好 7月16是什么星座 梦见家里办丧事是什么预兆
舌尖发麻是什么原因引起的 504是什么错误 先兆临产是什么意思 痛风吃什么 白蛋白偏低是什么原因
肌酐700多意味着什么 咬指甲是什么心理疾病 有什么赚钱的软件 阴道口痒用什么药好 纸包鸡什么意思
女人40不惑什么意思 正处级是什么级别 月经刚完同房为什么痛 紧急避孕药叫什么名字 老是做噩梦是什么原因
属猴的幸运色是什么颜色jinxinzhichuang.com 三国是什么朝代jiuxinfghf.com 生男孩女孩取决于什么aiwuzhiyu.com 锡纸什么牌子的好hcv8jop7ns6r.cn 因果循环是什么意思hcv7jop9ns2r.cn
第三代身份证什么时候开始办理hcv9jop8ns3r.cn 燕麦是什么hcv9jop7ns5r.cn 五行水多代表什么hcv9jop6ns3r.cn 山竹有什么功效hcv8jop5ns4r.cn 孕妇吃什么好对胎儿好三个月前期hcv9jop2ns2r.cn
梦见盖房子是什么预兆hcv8jop1ns6r.cn 什么血压计最准确hcv8jop4ns2r.cn 月经期同房有什么危害imcecn.com 舌苔发白是什么病的前兆hcv8jop6ns9r.cn 再生障碍性贫血是什么病hlguo.com
一个月不来月经是什么原因hcv7jop7ns2r.cn 什么时候排卵期hcv9jop1ns8r.cn 下午5点多是什么时辰hcv8jop8ns0r.cn 邪魅是什么意思hcv9jop3ns9r.cn 跑团是什么hcv7jop5ns2r.cn
百度