顺利是什么意思| 男人喝什么酒壮阳最快| 晚上很难入睡是什么原因| 入围是什么意思| 镇静是什么意思| 老夫老妻什么意思| 打磨工为什么没人干| 为什么一般不检查小肠| 小说be是什么意思| 没有美瞳护理液用什么代替| smile是什么意思| 什么样的人容易得痛风| 皮下脂肪瘤挂什么科| 不孕不育挂什么科| 幽门螺旋杆菌吃什么药最好| 成人改名字需要什么手续| 脸上出汗是什么原因| 痔疮初期症状是什么| 荷叶茶有什么功效| 老人流口水是什么原因引起的| 小孩腹泻吃什么药好得快| 心电图伪差是什么意思| 白细胞2个加号是什么意思| 头皮脂溢性皮炎用什么药| 莲雾是什么水果| 什么产品美白效果最好最快| 心率低是什么原因| 什么叫姑息治疗| 矗读什么| 过敏性皮肤用什么护肤品比较好| 粉刺是什么样的图片| 十一月十五号是什么星座| 六月初五是什么日子| 大姨妈期间适合吃什么水果| 空气棉是什么面料| 脸麻手麻是什么原因| 6月30日是什么日子| 鸟吃什么食物| 早上十点是什么时辰| 一什么黑暗| 风湿是什么原因造成的| 嗓子不舒服吃什么消炎药| 川崎病是什么原因引起的| 敏感什么意思| 前列腺炎是什么引起的| 女性乳房痒是什么原因| 196是什么意思| otto是什么意思| 狗咬了不能吃什么| 吃知柏地黄丸有什么副作用| 土豆不能和什么食物一起吃| 超声是什么检查| 瞬移是什么意思| 什么情况下要做肌电图| 甲状腺结节挂什么科| 日新月异什么意思| 拉尿有泡泡是什么原因| 下面痒用什么清洗最好| 滞纳金是什么| 梦到吃饭是什么意思| moncler是什么品牌| 岍是什么意思| 嗳气什么意思| 梦见前夫是什么兆头| 文献是什么| 鹅喜欢吃什么草| 1942年属什么生肖属相| 孕妇吃什么鱼对胎儿好| 阴道干涩用什么药| 坐月子吃什么水果| 肤浅是什么意思| 胆囊炎吃什么食物好| 舌头上有红点是什么原因| 类风湿和风湿有什么区别| 口红是什么做的| 宫颈炎是什么原因引起的| 农历5月是什么星座| 孕妇梦见水是什么意思| 办护照带什么资料| 婚检检查什么项目| 老婆生日送什么鲜花| 五六天不拉大便是什么原因| 精子成活率低吃什么药| 犹太人割礼是什么意思| 甲子日是什么意思| gcp是什么| 为什么会长汗斑| 叫什么| dob是什么意思| 疱疹吃什么药可以根治| 过敏性鼻炎吃什么食物好| 双龙什么| 手不释卷的释是什么意思| 大面积杀跳蚤用什么药| 秋天有什么植物| 香菇吃多了有什么危害| 石斛是什么东西| 乳头凹陷是什么原因| 服了是什么意思| 闲暇的意思是什么| 中位数是什么| 一把手是什么意思| 天蝎女喜欢什么样的男生| 空调室内机漏水是什么原因| 皮肤起小水泡很痒是什么原因| 大致正常心电图是什么意思| loa是什么意思| 健康管理是什么| 轻微食物中毒吃什么药| 什么官许愿| 手心发热吃什么药| 末那识是什么意思| 西安什么省| 小腿痒是什么原因| 淋巴发炎吃什么药好| 过敏性紫癜千万不能用什么药| 脊髓病变是什么病| 人乳头瘤病毒33型阳性是什么意思| 运动后喝什么水最好| 摘环后需要注意什么| 阿玛尼算什么档次| 臭鱼烂虾什么意思| 无与伦比是什么意思| 身份证后四位代表什么| 看望老人买什么礼物好| 11点到12点是什么时辰| 真菌涂片检查是查什么| 点卯是什么意思| 英国为什么叫日不落帝国| 中秋节送什么水果好| 胳膊困疼是什么原因| 欧巴桑什么意思| 结石吃什么食物好| 血糖高能吃什么蔬菜| 做鸡蛋饼用什么面粉好| 花枝是什么食材| 脑膜炎是什么原因引起的| 馨字取名有什么寓意| 什么东西含铅| 为什么会突然打嗝| 83年属什么| 山宗读什么| 宫颈纳氏囊肿是什么| CAT是什么| 天蝎座喜欢什么样的女生| tomboy是什么意思| 医保统筹是什么意思| 青霉素是什么药| 日逼是什么意思| 摩羯座什么时候| 14年属什么生肖| 甲减不能吃什么东西| 洗衣粉和洗衣液有什么区别| 浮肿是什么原因引起的| 反馈是什么意思| haze是什么意思| 后背痛是什么病的先兆| 湿疹为什么要查肝功能| 水痘是由什么引起的| image什么意思| 揠苗助长是什么意思| 起早贪黑是什么生肖| 月经黑色的是什么原因| 肝回声稍密是什么意思| 11月9日是什么日子| 大姨夫是什么| 象牙塔比喻什么| 萘普生是什么药| 作息时间是什么意思| 梦见别人打架是什么意思| 周星驰什么星座| 2r是什么意思| 兑水是什么意思| 油压是什么意思| 百香果吃了有什么好处| rag什么意思| 林冲是什么生肖| 悼念是什么意思| 神经炎用什么药| 水解奶粉是什么意思| 牛与什么生肖最配| 黎明破晓是什么意思| 短装是什么意思| 解脲支原体阳性是什么意思| 蹦蹦跳跳的动物是什么生肖| 心率慢吃什么药| 高血压需要注意些什么| 金晨什么星座| 养殖业什么最赚钱农村| 艾滋病的症状是什么| 有料是什么意思| 牙龈萎缩是什么原因造成的| 9月13日什么星座| 醋酸是什么面料| 眼皮跳什么预兆| 好五行属什么| 金银花有什么功效和作用| 77代表什么意思| 草酸是什么| gcp是什么意思| 耳目比喻什么| 动脉硬化挂什么科| 无妄是什么意思| bpm什么意思| 乳房胀痛什么原因| 牛头不对马嘴是什么意思| 月经期间可以喝什么汤比较好| c1开什么车| 尿多是什么原因引起的| 尿道灼热感吃什么药| 什么水果补血| 带状疱疹是什么引起的| 孕中期失眠是什么原因| 95年属什么生肖婚配表| 于心不忍是什么意思| 九月二十三是什么星座| 角膜塑形镜是什么| 学业有成是什么意思| 什么叫肠易激综合征| 牛肉和什么不能一起吃| 随机血糖是什么意思| 小腿肚抽筋是什么原因| 哪吒的武器是什么| ed50是什么意思| 语文是什么| 江西老表是什么意思| 什么样的人长寿| 腔梗和脑梗有什么区别| 破涕为笑什么意思| 211和985是什么意思| 海绵肾是什么意思| 拉青色大便是什么原因| 小孩子发烧手脚冰凉是什么原因| 多囊什么意思| 什么样人不能吃海参| aps是什么意思| 奎宁现在叫什么药| 囊肿有什么症状| 专案组是什么意思| 儿童超敏c反应蛋白高说明什么| 什么是熊猫血型| 六亲不认是什么生肖| 张家界地貌属于什么地貌| 饭中吃药是什么时候吃| 胃不好吃什么蔬菜| 盆腔炎有什么明显症状| 粉饼和散粉有什么区别| p医学代表什么意思| 增加胃动力最好的药是什么药| 灯光什么| 阿耨多罗三藐三菩提是什么意思| 来大姨妈不能吃什么| 桥本氏病是什么病| 脚底长痣有什么说法| 什么蔬菜补钾| 看甲沟炎挂什么科| 扁桃体切除有什么影响| 不想怀孕有什么办法| 生理曲度变直什么意思| 肺气不足吃什么食物可以补肺气| 胆囊炎要注意些什么| 从来不吃窝边草是什么生肖| 肌肉跳动是什么原因| 史无前例是什么意思| 百度Prije?i na sadr?aj

2017正风反腐怎么抓④:扎实推进监察体制改革

Izvor: Wikipedija
百度 对进入市场销售的野菜,要进行安全检验,由专业人员将毒草拦截在百姓的舌尖之外。

Dokumentaciju za ovaj modul mo?ete napraviti na stranici Modul:Math/dok

--[[

This module provides a number of basic mathematical operations.

]]

local yesno, getArgs -- lazily initialized

local p = {} -- Holds functions to be returned from #invoke, and functions to make available to other Lua modules.
local wrap = {} -- Holds wrapper functions that process arguments from #invoke. These act as intemediary between functions meant for #invoke and functions meant for Lua.

--[[
Helper functions used to avoid redundant code.
]]

local function err(msg)
	-- Generates wikitext error messages.
	return mw.ustring.format('<strong class="error">Formatting error: %s</strong>', msg)
end

local function unpackNumberArgs(args)
	-- Returns an unpacked list of arguments specified with numerical keys.
	local ret = {}
	for k, v in pairs(args) do
		if type(k) == 'number' then
			table.insert(ret, v)
		end
	end
	return unpack(ret)
end

local function makeArgArray(...)
	-- Makes an array of arguments from a list of arguments that might include nils.
	local args = {...} -- Table of arguments. It might contain nils or non-number values, so we can't use ipairs.
	local nums = {} -- Stores the numbers of valid numerical arguments.
	local ret = {}
	for k, v in pairs(args) do
		v = p._cleanNumber(v)
		if v then
			nums[#nums + 1] = k
			args[k] = v
		end
	end
	table.sort(nums)
	for i, num in ipairs(nums) do
		ret[#ret + 1] = args[num]
	end
	return ret
end

local function fold(func, ...)
	-- Use a function on all supplied arguments, and return the result. The function must accept two numbers as parameters,
	-- and must return a number as an output. This number is then supplied as input to the next function call.
	local vals = makeArgArray(...)
	local count = #vals -- The number of valid arguments
	if count == 0 then return
		-- Exit if we have no valid args, otherwise removing the first arg would cause an error.
		nil, 0
	end
	local ret = table.remove(vals, 1)
	for _, val in ipairs(vals) do
		ret = func(ret, val)
	end
	return ret, count
end

--[[
Fold arguments by selectively choosing values (func should return when to choose the current "dominant" value).
]]
local function binary_fold(func, ...)
	local value = fold((function(a, b) if func(a, b) then return a else return b end end), ...)
	return value
end

--[[
random

Generate a random number

Usage:
{{#invoke: Math | random }}
{{#invoke: Math | random | maximum value }}
{{#invoke: Math | random | minimum value | maximum value }}
]]

function wrap.random(args)
	local first = p._cleanNumber(args[1])
	local second = p._cleanNumber(args[2])
	return p._random(first, second)
end

function p._random(first, second)
	math.randomseed(mw.site.stats.edits + mw.site.stats.pages + os.time() + math.floor(os.clock() * 1000000000))
	-- math.random will throw an error if given an explicit nil parameter, so we need to use if statements to check the params.
	if first and second then
		if first <= second then -- math.random doesn't allow the first number to be greater than the second.
			return math.random(first, second)
		end
	elseif first then
		return math.random(first)
	else
		return math.random()
	end
end

--[[
order

Determine order of magnitude of a number

Usage:
{{#invoke: Math | order | value }}
]]

function wrap.order(args)
	local input_string = (args[1] or args.x or '0');
	local input_number = p._cleanNumber(input_string);
	if input_number == nil then
		return err('order of magnitude input appears non-numeric')
	else
		return p._order(input_number)
	end
end

function p._order(x)
	if x == 0 then return 0 end
	return math.floor(math.log10(math.abs(x)))
end

--[[
precision

Detemines the precision of a number using the string representation

Usage:
{{ #invoke: Math | precision | value }}
]]

function wrap.precision(args)
	local input_string = (args[1] or args.x or '0');
	local trap_fraction = args.check_fraction;
	local input_number;

	if not yesno then
		yesno = require('Module:Yesno')
	end
	if yesno(trap_fraction, true) then -- Returns true for all input except nil, false, "no", "n", "0" and a few others. See [[Module:Yesno]].
		local pos = string.find(input_string, '/', 1, true);
		if pos ~= nil then
			if string.find(input_string, '/', pos + 1, true) == nil then
				local denominator = string.sub(input_string, pos+1, -1);
				local denom_value = tonumber(denominator);
				if denom_value ~= nil then
					return math.log10(denom_value);
				end
			end
		end
	end

	input_number, input_string = p._cleanNumber(input_string);
	if input_string == nil then
		return err('precision input appears non-numeric')
	else
		return p._precision(input_string)
	end
end

function p._precision(x)
	if type(x) == 'number' then
		x = tostring(x)
	end
	x = string.upper(x)

	local decimal = x:find('%.')
	local exponent_pos = x:find('E')
	local result = 0;

	if exponent_pos ~= nil then
		local exponent = string.sub(x, exponent_pos + 1)
		x = string.sub(x, 1, exponent_pos - 1)
		result = result - tonumber(exponent)
	end

	if decimal ~= nil then
		result = result + string.len(x) - decimal
		return result
	end

	local pos = string.len(x);
	while x:byte(pos) == string.byte('0') do
		pos = pos - 1
		result = result - 1
		if pos <= 0 then
			return 0
		end
	end

	return result
end


--[[
max

Finds the maximum argument

Usage:
{{#invoke:Math| max | value1 | value2 | ... }}

Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.max(args)
	return p._max(unpackNumberArgs(args))
end

function p._max(...)
	local max_value = binary_fold((function(a, b) return a > b end), ...)
	if max_value then
		return max_value
	end
end

--[[
median

Find the median of set of numbers

Usage:
{{#invoke:Math | median | number1 | number2 | ...}}
OR
{{#invoke:Math | median }}
]]

function wrap.median(args)
	return p._median(unpackNumberArgs(args))
end

function p._median(...)
	local vals = makeArgArray(...)
	local count = #vals
	table.sort(vals)

	if count == 0 then
		return 0
	end

	if p._mod(count, 2) == 0 then
		return (vals[count/2] + vals[count/2+1])/2
	else
		return vals[math.ceil(count/2)]
	end
end

--[[
min

Finds the minimum argument

Usage:
{{#invoke:Math| min | value1 | value2 | ... }}
OR
{{#invoke:Math| min }}

When used with no arguments, it takes its input from the parent
frame.  Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.min(args)
	return p._min(unpackNumberArgs(args))
end

function p._min(...)
	local min_value = binary_fold((function(a, b) return a < b end), ...)
	if min_value then
		return min_value
	end
end

--[[
sum

Finds the sum

Usage:
{{#invoke:Math| sum | value1 | value2 | ... }}
OR
{{#invoke:Math| sum }}

Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.sum(args)
	return p._sum(unpackNumberArgs(args))
end

function p._sum(...)
	local sums, count = fold((function(a, b) return a + b end), ...)
	if not sums then
		return 0
	else
		return sums
	end
end

--[[
average

Finds the average

Usage:
{{#invoke:Math| average | value1 | value2 | ... }}
OR
{{#invoke:Math| average }}

Note, any values that do not evaluate to numbers are ignored.
]]

function wrap.average(args)
	return p._average(unpackNumberArgs(args))
end

function p._average(...)
	local sum, count = fold((function(a, b) return a + b end), ...)
	if not sum then
		return 0
	else
		return sum / count
	end
end

--[[
round

Rounds a number to specified precision

Usage:
{{#invoke:Math | round | value | precision }}

--]]

function wrap.round(args)
	local value = p._cleanNumber(args[1] or args.value or 0)
	local precision = p._cleanNumber(args[2] or args.precision or 0)
	if value == nil or precision == nil then
		return err('round input appears non-numeric')
	else
		return p._round(value, precision)
	end
end

function p._round(value, precision)
	local rescale = math.pow(10, precision or 0);
	return math.floor(value * rescale + 0.5) / rescale;
end

--[[
log10

returns the log (base 10) of a number

Usage:
{{#invoke:Math | log10 | x }}
]]

function wrap.log10(args)
	return math.log10(args[1])
end

--[[
mod

Implements the modulo operator

Usage:
{{#invoke:Math | mod | x | y }}

--]]

function wrap.mod(args)
	local x = p._cleanNumber(args[1])
	local y = p._cleanNumber(args[2])
	if not x then
		return err('first argument to mod appears non-numeric')
	elseif not y then
		return err('second argument to mod appears non-numeric')
	else
		return p._mod(x, y)
	end
end

function p._mod(x, y)
	local ret = x % y
	if not (0 <= ret and ret < y) then
		ret = 0
	end
	return ret
end

--[[
gcd

Calculates the greatest common divisor of multiple numbers

Usage:
{{#invoke:Math | gcd | value 1 | value 2 | value 3 | ... }}
--]]

function wrap.gcd(args)
	return p._gcd(unpackNumberArgs(args))
end

function p._gcd(...)
	local function findGcd(a, b)
		local r = b
		local oldr = a
		while r ~= 0 do
			local quotient = math.floor(oldr / r)
			oldr, r = r, oldr - quotient * r
		end
		if oldr < 0 then
			oldr = oldr * -1
		end
		return oldr
	end
	local result, count = fold(findGcd, ...)
	return result
end

--[[
precision_format

Rounds a number to the specified precision and formats according to rules
originally used for {{template:Rnd}}.  Output is a string.

Usage:
{{#invoke: Math | precision_format | number | precision }}
]]

function wrap.precision_format(args)
	local value_string = args[1] or 0
	local precision = args[2] or 0
	return p._precision_format(value_string, precision)
end

function p._precision_format(value_string, precision)
	-- For access to Mediawiki built-in formatter.
	local lang = mw.getContentLanguage();

	local value
	value, value_string = p._cleanNumber(value_string)
	precision = p._cleanNumber(precision)

	-- Check for non-numeric input
	if value == nil or precision == nil then
		return err('invalid input when rounding')
	end

	local current_precision = p._precision(value)
	local order = p._order(value)

	-- Due to round-off effects it is neccesary to limit the returned precision under
	-- some circumstances because the terminal digits will be inaccurately reported.
	if order + precision >= 14 then
		if order + p._precision(value_string) >= 14 then
			precision = 13 - order;
		end
	end

	-- If rounding off, truncate extra digits
	if precision < current_precision then
		value = p._round(value, precision)
		current_precision = p._precision(value)
	end

	local formatted_num = lang:formatNum(math.abs(value))
	local sign

	-- Use proper unary minus sign rather than ASCII default
	if value < 0 then
		sign = '?'
	else
		sign = ''
	end

	-- Handle cases requiring scientific notation
	if string.find(formatted_num, 'E', 1, true) ~= nil or math.abs(order) >= 9 then
		value = value * math.pow(10, -order)
		current_precision = current_precision + order
		precision = precision + order
		formatted_num = lang:formatNum(math.abs(value))
	else
		order = 0;
	end
	formatted_num = sign .. formatted_num

	-- Pad with zeros, if needed
	if current_precision < precision then
		local padding
		if current_precision <= 0 then
			if precision > 0 then
				local zero_sep = lang:formatNum(1.1)
				formatted_num = formatted_num .. zero_sep:sub(2,2)

				padding = precision
				if padding > 20 then
					padding = 20
				end

				formatted_num = formatted_num .. string.rep('0', padding)
			end
		else
			padding = precision - current_precision
			if padding > 20 then
				padding = 20
			end
			formatted_num = formatted_num .. string.rep('0', padding)
		end
	end

	-- Add exponential notation, if necessary.
	if order ~= 0 then
		-- Use proper unary minus sign rather than ASCII default
		if order < 0 then
			order = '?' .. lang:formatNum(math.abs(order))
		else
			order = lang:formatNum(order)
		end

		formatted_num = formatted_num .. '<span style="margin:0 .15em 0 .25em">×</span>10<sup>' .. order .. '</sup>'
	end

	return formatted_num
end

--[[
divide

Implements the division operator

Usage:
{{#invoke:Math | divide | x | y | round= | precision= }}

--]]
function wrap.divide(args)
	local x = args[1]
	local y = args[2]
	local round = args.round
	local precision =  args.precision
	if not yesno then
		yesno = require('Module:Yesno')
	end
	return p._divide(x, y, yesno(round), precision)
end

function p._divide(x, y, round, precision)
	if y == nil or y == "" then
		return err("Empty divisor")
	elseif not tonumber(y) then
		if type(y) == 'string' and string.sub(y, 1, 1) == '<' then
			return y
		else
			return err("Not a number: " .. y)
		end
	elseif x == nil or x == "" then
		return err("Empty dividend")
	elseif not tonumber(x) then
		if type(x) == 'string' and string.sub(x, 1, 1) == '<' then
			return x
		else
			return err("Not a number: " .. x)
		end
	else
		local z = x / y
		if round then
			return p._round(z, 0)
		elseif precision then
			return p._round(z, precision)
		else
			return z	
		end
	end
end

--[[
Helper function that interprets the input numerically.  If the
input does not appear to be a number, attempts evaluating it as
a parser functions expression.
]]

function p._cleanNumber(number_string)
	if type(number_string) == 'number' then
		-- We were passed a number, so we don't need to do any processing.
		return number_string, tostring(number_string)
	elseif type(number_string) ~= 'string' or not number_string:find('%S') then
		-- We were passed a non-string or a blank string, so exit.
		return nil, nil;
	end

	-- Attempt basic conversion
	local number = tonumber(number_string)

	-- If failed, attempt to evaluate input as an expression
	if number == nil then
		local success, result = pcall(mw.ext.ParserFunctions.expr, number_string)
		if success then
			number = tonumber(result)
			number_string = tostring(number)
		else
			number = nil
			number_string = nil
		end
	else
		number_string = number_string:match("^%s*(.-)%s*$") -- String is valid but may contain padding, clean it.
		number_string = number_string:match("^%+(.*)$") or number_string -- Trim any leading + signs.
		if number_string:find('^%-?0[xX]') then
			-- Number is using 0xnnn notation to indicate base 16; use the number that Lua detected instead.
			number_string = tostring(number)
		end
	end

	return number, number_string
end

--[[
Wrapper function that does basic argument processing. This ensures that all functions from #invoke can use either the current
frame or the parent frame, and it also trims whitespace for all arguments and removes blank arguments.
]]

local mt = { __index = function(t, k)
	return function(frame)
		if not getArgs then
			getArgs = require('Module:Arguments').getArgs
		end
		return wrap[k](getArgs(frame))  -- Argument processing is left to Module:Arguments. Whitespace is trimmed and blank arguments are removed.
	end
end }

return setmetatable(p, mt)
个子矮吃什么才能长高 吃炒黄豆有什么好处和坏处 戴菊是什么 闪回是什么意思 什么叫轻度脂肪肝
过敏性荨麻疹吃什么药 cpi什么意思 球虫病有什么症状 什么的挑选 虾不能和什么东西一起吃
什么为力 力什么神什么 肉桂属于什么茶 滴虫性阴道炎吃什么药 c罗穿什么足球鞋
吃什么减肥 什么是呼吸性碱中毒 梦见大水牛是什么兆头 什么的秃鹫 每次上大便都出血是什么原因
lpn什么意思hcv8jop9ns9r.cn 脚底出汗是什么原因女hcv8jop7ns8r.cn 绵密是什么意思hcv8jop3ns9r.cn 一个女一个以念什么cl108k.com mtt什么意思hcv9jop2ns1r.cn
脉搏快是什么原因hcv9jop2ns0r.cn 蛇进家是什么意思hcv8jop9ns1r.cn 牙齿为什么会松动hcv8jop6ns1r.cn 心灵鸡汤什么意思kuyehao.com sheen是什么牌子的手表sscsqa.com
造势是什么意思gysmod.com 疱疹用什么药hcv8jop3ns6r.cn 女性尿道炎吃什么药hcv8jop9ns7r.cn 恪尽职守是什么意思hcv7jop5ns3r.cn 低钾是什么原因造成的hcv9jop4ns3r.cn
曲率是什么意思onlinewuye.com 慢性胃炎要吃什么药qingzhougame.com 快乐源泉是什么意思hcv8jop4ns3r.cn 孕妇便秘吃什么水果hcv8jop0ns1r.cn smt是什么hcv7jop9ns4r.cn
百度