小孩拉肚子应该吃什么食物好| 蔬菜都有什么| 结肠炎吃什么药| 最大的行星是什么| 喝豆浆有什么好处和坏处| 尿常规是检查什么的| 癣用什么药| aso是什么意思| fredperry是什么牌子| 你说到底为什么都是我的错| 看眼睛挂什么科| 胃不好不能吃什么| 梦见自己生病住院了是什么意思| nuxe是什么牌子护肤品| nadh是什么| 什么万千| 可燃冰属于什么能源| 生气过度会气出什么病| 晚上睡觉口苦是什么原因| 味极鲜是什么| 山药为什么煮熟了也麻口| 蒙脱石是什么东西| 喇叭裤配什么上衣| 三月份是什么季节| 特警力量第二部叫什么| 拜阿司匹林什么时间吃最好| 儿童腮腺炎吃什么药| 头晕恶心想吐挂什么科| 右侧疼痛是什么原因| 三里屯有什么好玩的地方| 梦到买房子是什么意思| 喝芝麻糊有什么好处| 零八年属什么| 梦见牙掉了一颗是什么意思| 肺部肿瘤吃什么好| 首善是什么意思| 3岁小孩不会说话是什么原因| 率真是什么意思| 夏花是什么意思| 7月12是什么星座| 微信上面有个耳朵是什么意思| 长绒棉和全棉什么区别| 突然便秘是什么原因引起的| 晚上尿多是什么原因| 奥运会五环颜色分别代表什么| 做胃镜挂什么科| 强痛定又叫什么| lr是什么意思| 丈青色是什么颜色| 高铁上不能带什么东西| 什么叫闰年| 桥本甲状腺炎吃什么药| salsa什么意思| 鼠肚鸡肠是什么生肖| 真情流露是什么意思| 断流什么意思| 诗经又称什么| 爱因斯坦发明了什么| 牛油果不能和什么一起吃| 见字五行属什么| 鱼子酱是什么鱼| 吃什么食物排湿气| 阑尾炎手术后可以吃什么| 1.7号是什么星座| 背靠背协议是什么意思| 备是什么意思| 为什么说肺结核是穷人病| 男龙和什么生肖最配| 武则天是什么朝代| 大脑供血不足吃什么药最好| 女人三十如狼四十如虎什么意思| 表面积是什么意思| 喉咙发甜是什么原因| 睡觉吐气是什么原因| dwi呈高信号什么意思| 两点水的字和什么有关| 蒸鱼豉油可以用什么代替| 莫代尔是什么面料| 属实是什么意思| btc是什么货币| 夜阑珊是什么意思| 1893年属什么生肖| 1989年五行属什么| 氯读什么拼音| 贫血缺什么| 刮痧有什么作用| 一什么木屋| 碱性磷酸酶高是什么意思| 血管瘤是什么样子的| 马头琴是什么族的乐器| 梦见前女友是什么预兆| 狗鼻子为什么是湿的| 榆字五行属什么| lee是什么档次| 巴适是什么意思| 冬瓜什么时候种植最好| 香蕉补什么| 月经期血块多是什么原因| 一什么话| 什么的荷花| 什么是风热感冒| 汉朝后面是什么朝代| 胃胀吃什么药最有效| 甲状腺球蛋白抗体高说明什么| 眼珠子发黄是什么原因| 火钳刘明什么意思| 快乐是什么意思| 怀孕有什么表现| 投诉医院打什么电话| 房颤是什么| 猫贫血吃什么补血最快| 熟褐色是什么颜色| 孽缘是什么意思| 小孩指甲有白点是什么原因| 灰面是什么面粉| 眼睛干涩有异物感用什么眼药水| 多酚是什么| 非农业户口是什么意思| 乳化是什么意思| 嘴巴里甜甜的是什么原因| 喉咙痒咳嗽有痰是什么原因| 龟头炎用什么软膏最好| 既往病史是什么意思| 健脾祛湿吃什么中成药| 什么又什么又什么| 白带什么样| 炖鸡肉放什么调料| 处男是什么| 六月十一是什么星座| 随访复查什么意思| 吃晕车药有什么副作用| 火乐读什么| 脊椎炎什么症状| 姑婆的儿子叫什么| 月经推迟十天是什么原因| 现在流行什么| 今年52岁属什么生肖| 间歇性跛行见于什么病| 皮赘是什么| 拼图用什么软件| 倒模是什么| 大数据是什么专业| 孔子的父亲叫什么| 人流后吃什么补身体| 胃胀吃什么药| 补气血吃什么食物| 蛤蜊是什么| 相思成疾是什么意思| 吃什么水果减肥最快减肚子| 怀孕前三个月需要注意什么| 总胆汁酸高是什么意思| 疲惫是什么意思| 待产是什么意思| 什么是塔罗牌| 省政协主席什么级别| 淡定从容是什么意思| 什么叫射频消融| 靶向药是什么药| 江米和糯米有什么区别| 好好好是什么语气| 什么是梭织面料| 指甲上有竖纹是什么原因| 平行班是什么意思| 进国企需要什么条件| 宝宝说话晚是什么原因造成的| 鹅肉不能和什么一起吃| 小t是什么意思| 牙疼吃什么药效果好| 今日立冬吃什么| 2月24是什么星座| 孕妇喝什么茶对胎儿好| 子宫内膜薄是什么原因造成的| 阿司匹林肠溶片什么时候吃| 错付是什么意思| 宰相相当于现在什么官| 奥运会五环颜色分别代表什么| 打呼噜有什么危害| 痛风能吃什么肉| 膝盖内侧疼吃什么药| 栀子对妇科有什么功效| 一个黑一个俊的右边念什么| 11月4号是什么星座| 女生自慰是什么感觉| 鸡头米什么时候上市| 留级是什么意思| 地府是什么意思| 吃什么食物养肝| 剪短发什么发型好看| 陌路人是什么意思| 时至今日是什么意思| 吃完紧急避孕药不能吃什么| 两个马念什么| 经常咳嗽是什么病| leep是什么意思| 宰相相当于现在什么官| 宫腔回声不均匀什么原因| 花儿为什么那么红| 1959年属什么| 可乐是什么做的| dady是什么意思| 男生说gg是什么意思| 荠菜长什么样子图片| 为什么会突然流鼻血| 为什么吃饱了就犯困| 尖货是什么意思| 新生儿为什么会有黄疸| 利空什么意思| 扁平疣用什么药膏| 什么各异| 人被老鼠咬了什么预兆| 高密度脂蛋白是什么意思| 四叶草项链是什么牌子| 过意不去是什么意思| 手心热吃什么药| 什么水果糖分最高| 磨豆浆是什么意思| hpc是什么| 小孩肚子疼吃什么药好| 鳞状上皮是什么意思| 13颗珠子的手串什么意思| 早上起床想吐是什么原因| 始祖鸟是什么鸟| 喝什么粥养胃| 九五年属什么生肖| 男性内分泌失调有什么症状| 地级市市长什么级别| 黑上衣配什么颜色裤子男| 慢性前列腺炎有什么症状| dbm是什么单位| 肌肉劳损吃什么药| 什么人不适合吃海参| 乳房发烫胀痛什么原因| 老子是什么时期的人| 兄弟是什么生肖| 巨蟹女和什么座最配对| 武汉属于什么地区| 阴虚和阳虚有什么区别的症状| 私密瘙痒是什么原因| 小狗能看见什么颜色| 妇科检查白细胞酯酶阳性是什么意思| 咳血是什么原因| 脾虚喝什么泡水比较好| 破伤风是什么意思| b细胞淋巴肿瘤是一种什么病| 阴历六月是什么月| hp感染是什么病| 男的叫少爷女的叫什么| 立flag什么意思| 筋膜炎挂什么科| 为什么蚊子咬了会起包| 申时是什么时候| 戾什么意思| 艺五行属性是什么| 镜里观花是什么生肖| 什么泡水喝杀幽门螺杆菌| 杯酒释兵权是什么意思| 头痛应该挂什么科| 副高相当于什么级别| 熬中药用什么锅| 精神可嘉是什么意思| 戒烟后为什么会发胖| 垂体催乳素高是什么原因| 女生月经不规律的原因是什么| 老是腹泻是什么原因导致的| 百度

Fami通杂志曝《高达VS》将加入双头龙和艾比安高达

百度 随后,山西焦煤西山煤电下发《关于对集团煤炭生产企业艰苦岗位津贴免征个人所得税的通知》明确:煤矿一线等人员领取的井下津贴、夜班津贴,每月在计算个人所得税时,可以享受扣除政策。

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

--[[

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
		orig_precision = p._precision(value_string)
		if order + orig_precision >= 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

--[[
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)
c2驾驶证能开什么车 不孕不育做什么检查 吉代表什么生肖 nt是什么意思 腰疼是什么原因引起的男性
旦上面加一横是什么字 阴险表情什么意思 女性吃大肠有什么好处 孔子名什么 地素女装属于什么档次
中药包煎是什么意思 鱼子酱是什么鱼 精气是什么意思 roger是什么意思 三叉神经痛挂什么科就诊
红糖有什么功效 斑秃吃什么药效果好 May什么意思 酸溜溜的什么 唇珠在面相中代表什么
长期尿黄可能是什么病hcv9jop2ns4r.cn dunk是什么意思hcv9jop3ns0r.cn 当归长什么样的图片hcv9jop5ns4r.cn 吃什么补雌激素最快hcv8jop2ns3r.cn 送什么小礼品好hcv9jop2ns8r.cn
hl代表什么hcv9jop0ns4r.cn 寄居蟹吃什么hcv8jop9ns2r.cn 吃什么补眼睛chuanglingweilai.com 奇经八脉指的是什么hcv9jop3ns5r.cn 聚酯纤维是什么材料hcv8jop1ns1r.cn
槲皮素是什么东西hcv9jop0ns2r.cn 骶管小囊肿是什么意思weuuu.com 小孩口臭吃什么药hcv9jop2ns6r.cn 肾病什么症状hcv8jop0ns2r.cn 挂名什么意思hcv8jop7ns1r.cn
吃什么长高hcv8jop6ns7r.cn gi是什么意思hcv8jop4ns6r.cn 心悸失眠是什么症状hcv9jop1ns6r.cn 频繁流鼻血是什么病的前兆hcv9jop7ns3r.cn 脑电图是什么hcv9jop3ns0r.cn
百度