grader是什么意思| 预谋什么意思| 煞北是什么意思| 什么花的花语是自由| 备胎是什么意思| 仙人掌能治什么病| 一个万一个足念什么| 下海什么意思| 巡警是做什么的| 脚底板发红是什么原因| 褐色分泌物是什么原因引起的| 天天射精对身体有什么危害| 乌鱼蛋是什么| 卿卿是什么意思| 肌酐清除率是什么意思| bmi指数是什么| 蓬灰是什么东西| 复制是什么意思| 脸基尼是什么意思| 花团锦簇什么意思| 孤臣是什么意思| 层林尽染是什么季节| 月经不调挂什么科| 恋恋不舍的意思是什么| 1月29号什么星座| mps是什么意思| 官符是什么意思| lpn什么意思| 坐享其成是什么意思| 3月28日什么星座| 2043年是什么年| 八字不合是什么生肖| 手链突然断了预示什么| 宝宝吃什么鱼比较好| 拍立得相纸为什么这么贵| 幼小衔接班主要教什么| 阴阳两虚吃什么药| 1994年的狗是什么命| 扑救带电火灾应选用什么灭火器| 剧透是什么意思| 瓜蒌根为什么叫天花粉| 安全生产职责是什么| 保险公司最怕什么投诉| 下眼睑浮肿是什么原因| 什么冰淇淋最贵| 透析是什么| 儿保是什么| 吃什么补性功能最快| 内痔疮有什么症状| 大盘是什么意思| 青苹果什么时候成熟| ppm是什么意思| 血常规主要检查什么| naoh是什么| 什么东东是什么意思| 全身痒是什么原因| 孕妇做糖筛是检查什么| 属龙的和什么属相最配| 抽血抽不出来是什么原因| 什么生花| 去台湾需要什么证件| 男人趴着睡觉说明什么| 清洁度lv是什么意思| 扁桃体发炎吃什么食物好| 明朝后面是什么朝代| 咖啡过敏的症状是什么| 舌头发麻是什么原因| 得了子宫肌瘤注意什么| 玄胡又叫什么| 电焊打眼最有效最快的方法是什么| hpa是什么单位| 试纸一深一浅说明什么| 燕条和燕盏有什么区别| 梦见刷牙是什么预兆| 黄瓜敷脸有什么作用与功效| 宫颈炎是什么病| 佰草集适合什么年龄| 猪日冲蛇什么意思| 裂纹舌是什么原因| 三七粉是什么| 尿里带血是什么原因| 葫芦是什么生肖| 清酒和白酒有什么区别| 一点小事就暴躁的人是什么病| 秋高气爽是什么意思| 1975年是什么命| 四不放过是什么| 倒打一耙的前一句是什么| 河虾最爱吃什么食物| 三个小是什么字| 藜麦是什么| 一代宗师是什么意思| 眼睛痒是什么原因| 耽美剧是什么意思| 什么是掌跖脓疱病| 武夷水仙茶属于什么茶| 骨加客读什么| 酸菜鱼一般用什么鱼| 小孩表演后卸妆用什么| 草酸钙结晶是什么意思| 崖柏对人体有什么好处| 小狗感冒吃什么药| 血热吃什么好| 23年属什么| 尿为什么是黄色的| 宝宝在肚子里打嗝是什么原因| 着凉感冒吃什么药| 什么叫根管治疗| 茯砖茶是什么茶| 送男生什么生日礼物| 水煮鱼用什么鱼做好吃| 更年期失眠吃什么药效果好| 男性泌尿道感染吃什么药| 什么充电宝能带上飞机| 毫不逊色的意思是什么| 什么原因引起荨麻疹| 忐忑不安是什么意思| 滋生是什么意思| 尿频繁吃什么药最见效| 束在什么情况下读su| 愚昧是什么意思| 什么是粘胶纤维| 乳腺结节吃什么好| 血小板分布宽度偏高是什么意思| 巨蟹女跟什么星座最配| 拉肚子用什么药| 右侧附件区囊性回声是什么意思| 一什么瓜地| 大白片是什么药| 洗发水和洗发露有什么区别| 皮肤有白点是什么原因| 吃蓝莓有什么好处| 痛风不能吃什么食物表| 4.14是什么星座| 红红火火是什么生肖| 饮食清淡的标准是什么| 大学硕士点是什么意思| 庸人自扰是什么意思| 负距离接触是什么意思| 胆囊壁不光滑是什么意思| 舌苔厚黄是什么病| 怀孕的脉搏和正常脉搏有什么区别| 处女男和什么星座最配| 为什么会有高血压| 煤气罐在什么情况下会爆炸| 气血虚吃什么中成药| 手指甲软薄是缺什么| 孩子发烧手脚冰凉是什么原因| 戾气太重是什么意思| 6月30日是什么节日| 咖啡过敏的症状是什么| 脱水什么意思| 脾大吃什么可以缩脾| 赛诺菲是什么药| 什么是热性水果| 为什么怀不上孕| 公丁香和母丁香有什么区别| 威士忌是用什么酿造的| 国家穷为什么不多印钱| 嘚瑟是什么意思| 大油边是什么肉| 双向情感障碍吃什么药| 埋线是什么| 一个鸟一个木念什么| 爸爸过生日送什么礼物| 野鸭子吃什么| 苦丁茶有什么作用和功效| 七月一号什么星座| 左肺结节是什么意思| 乙肝是什么病严重吗| 大熊猫生活在什么地方| 多糖是什么| 什么叫性生活| 鸡眼膏为什么越贴越疼| 话费为什么扣那么快| 后脖子出汗多是什么原因| 小水滴会变成什么| 黔驴技穷什么意思| 属狗的幸运色是什么颜色| 什么时候开始孕吐| 什么蔬菜是温性的| 缅怀是什么意思| 什么的奇观| 1114是什么星座| 端字五行属什么| 软肋是什么意思| 湖北有什么山| 词牌名什么意思| 深海鱼油有什么作用| 细菌感染是什么原因| 心力憔悴是什么意思| 床上什么虫子夜间咬人| 阴虚火旺有什么表现症状| 幡然醒悟是什么意思| 一个虫一个卑念什么| 肾结石什么不可以吃| 一什么明珠| 水险痣是什么意思| 贴黄瓜片对皮肤有什么好处| 望穿秋水的意思是什么| 胃痛吃什么药| 喉咙不舒服挂什么科| 纳是什么意思| 阿达是什么意思| 生化妊娠是什么意思| 无缘无故流鼻血是什么原因| 一直发低烧是什么原因| 三七粉是治什么病的| 白鹭吃什么| 黑色素沉淀是什么原因引起的| 友谊是什么意思| 艾草治什么病| 什么鸡没有翅膀| p4是什么意思| 胸腔疼痛是什么原因| 伟五行属什么| 胃在什么位置| 酒后喝什么解酒| 肺气不足吃什么药| 恶心头晕是什么症状| 淤青擦什么药| 拉肚子吃什么水果好| 腊八有什么讲究| 杨家将是什么生肖| 维生素d补什么| 内科主要看什么病| 阴唇肥大有什么影响| 甲状腺属于什么科室| 报道是什么意思| 摸摸唱是什么意思| 彩虹为什么有七种颜色| 梦见自己找工作是什么意思| 树脂材料是什么| 三季人是什么意思| 可颂是什么意思| 不问世事什么意思| 宝宝大便发白是什么原因| 顺手牵羊是什么生肖| 乌鸡炖什么好吃又有营养| 新生儿老是打嗝是什么原因| 小便有点红是什么原因| 荡气回肠什么意思| 甲亢和甲状腺有什么区别| 青蛙属于什么类动物| 老戏骨是什么意思| 结婚送什么| 开字五行属什么| 咖啡为什么提神| 20年是什么年| ck属于什么档次的品牌| 心急吃不了热豆腐什么意思| 九月一号是什么节日| lst是什么意思| 出汗多是什么原因| 婚煞是什么意思| 天天睡觉做梦是什么原因| 手淫过多会导致什么| 月亮星座是什么| 什么的贝壳| 蝙蝠怕什么| ur是什么品牌| 40年什么婚| 鼻子红是什么原因| 脚底出汗是什么原因| 百度Jump to content

英文直播|古代海上丝绸之路始发港焕发新活力

From Wikibooks, open books for an open world
百度     据报道,北京经济技术开发区荣华中路的路口位置已经竖立起多块“自动驾驶测试路段”标识牌。
------------------------------------------------------------------------------------
--                                   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
		else
			if not exists[v] then
				ret[#ret + 1] = v
				exists[v] = true
			end
		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)
	-- Stores copies of tables indexed by the original table.
	already_seen = already_seen or {}

	local copy = already_seen[orig]
	if copy ~= nil then
		return copy
	end

	if type(orig) == 'table' then
		copy = {}
		for orig_key, orig_value in pairs(orig) do
			copy[_deepCopy(orig_key, includeMetatable, already_seen)] = _deepCopy(orig_value, includeMetatable, already_seen)
		end
		already_seen[orig] = copy

		if includeMetatable then
			local mt = getmetatable(orig)
			if mt ~= nil then
				local mt_copy = _deepCopy(mt, includeMetatable, already_seen)
				setmetatable(copy, mt_copy)
				already_seen[mt] = mt_copy
			end
		end
	else -- number, string, boolean, etc
		copy = orig
	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)
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 valueToFind is a member of the array, and false otherwise.
------------------------------------------------------------------------------------
function p.inArray(arr, valueToFind)
	checkType("inArray", 1, arr, "table")
	-- if valueToFind is nil, error?

	for _, v in ipairs(arr) do
		if v == valueToFind then
			return true
		end
	end
	return false
end

return p
淋巴细胞偏高说明什么 一个火一个日一个立念什么 右边脑袋疼是什么原因 身体缺硒有什么症状 月经一个月来两次是什么原因
什么样的大山 电压高是什么原因造成 氨水对人体有什么危害 什么生肖站着睡觉 什么叫卒中
什么清肠茶好 猫肉什么味道 客服是什么意思 玛卡是什么 结婚50年是什么婚
痔疮手术后可以吃什么水果 小米粥和什么搭配最好最养胃 扁桃体结石挂什么科 奥倍健是什么药 1957年发生了什么
胃酸是什么xinjiangjialails.com 脑萎缩挂什么科ff14chat.com 切花是什么意思hcv9jop2ns7r.cn 隐形眼镜护理液可以用什么代替hcv9jop4ns3r.cn 法令纹深是什么原因hcv7jop4ns6r.cn
属猪男配什么属相最好hcv9jop2ns5r.cn ber什么意思gangsutong.com 稽留热常见于什么病hcv8jop4ns9r.cn 痔疮嵌顿是什么意思hcv9jop7ns4r.cn 头疼想吐是什么原因引起的ff14chat.com
女性生活疼痛什么原因hcv7jop5ns5r.cn 游园惊梦讲的是什么hcv7jop4ns6r.cn 中耳炎用什么药最好hcv9jop6ns6r.cn 梦见浇花是什么意思hcv9jop6ns5r.cn 飞机加什么油cl108k.com
为什么很多人不去庐山xinjiangjialails.com 补铁的水果有什么hcv8jop5ns7r.cn 腿部抽筋是什么原因hcv9jop4ns8r.cn 就这样吧是什么意思hcv8jop5ns9r.cn 白绫是什么意思hcv8jop5ns9r.cn
百度