跳转到内容

模組:Complex Number/Calculate/Operators

本页使用了标题或全文手工转换
被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由A2569875留言 | 贡献2020年3月7日 (六) 20:58 建立内容为“local p={} p.symbol_table = { ['+'] = { propetry="op", multp = true, count = 2, priority=6, ppriority=6, calc=function(a,b,c,d)return d(a)+d(b) en…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)

local p={}
p.symbol_table = {
		['+'] = { propetry="op", multp = true, count = 2, priority=6, ppriority=6, calc=function(a,b,c,d)return d(a)+d(b) end},
		["+ "] = { propetry="op", count = 1, priority=10, ppriority=10, calc=function(a,c,d)return d(a) end},
		['-'] = { propetry="op", multp = true, count = 2, priority=6, ppriority=6, calc=function(a,b,c,d)return d(a)-d(b) end},
		["- "] = { propetry="op", count = 1, priority=10, ppriority=10, calc=function(a,c,d)return -d(a) end},
		['*'] = { propetry="op", multp = true, count = 2, priority=7, ppriority=7, calc=function(a,b,c,d)return d(a)*d(b) end},
		["* "] = { propetry="op", count = 1, priority=10, ppriority=10, calc=function(a,c,d) if type(c.conjugate)==type(function()end) then return c.conjugate(d(a))else return d(a)end end},
		['/'] = { propetry="op", count = 2, priority=7, ppriority=7, calc=function(a,b,c,d)return d(a)/d(b) end},
		['%'] = { propetry="op", count = 2, priority=7, ppriority=7, calc=function(a,b,c,d)return d(a)%d(b) end},
		['^'] = { propetry="op", count = 2, priority=9, ppriority=8, calc=function(a,b,c,d)return c.pow(d(a),d(b)) end},
		[','] = { propetry="op", count = 2, priority=1, ppriority=1 },
		['='] = { propetry="op", count = 2, priority=3, ppriority=3, calc=function(a,b,c,d)return type(c.matheq)==type(function()end)and c.matheq(d(a),d(b))or d(d(a)==d(b)and 1 or 0)end},
		['≠'] = { propetry="op", count = 2, priority=3, priority=3, calc=function(a,b,c,d)return type(c.mathneq)==type(function()end)and c.mathneq(d(a),d(b))or d(d(a)~=d(b)and 1 or 0)end},
		['←'] = { propetry="op", count = 2, priority=5, ppriority=5, calc=function(a,b,c,d)return type(c.mathdef)==type(function()end)and c.mathdef(d(a),d(b))or b end},
		['>'] = { propetry="op", count = 2, priority=4, ppriority=4, calc=function(a,b,c,d)
			if type(c.mathgt)==type(function()end) then return c.mathgt(d(a),d(b)) end
			if c.abs(c.nonRealPart(d(a))) > 1e-14 or c.abs(c.nonRealPart(d(b))) > 1e-14 then return 0 end
			return d(c.re(d(a))>c.re(d(b))and 1 or 0)
		end},
		['<'] = { propetry="op", count = 2, priority=4, ppriority=4, calc=function(a,b,c,d)
			if type(c.mathlt)==type(function()end) then return c.mathlt(d(a),d(b)) end
			if c.abs(c.nonRealPart(d(a))) > 1e-14 or c.abs(c.nonRealPart(d(b))) > 1e-14 then return 0 end
			return d(c.re(d(a))<c.re(d(b))and 1 or 0)
		end},
		['≥'] = { propetry="op", count = 2, priority=4, ppriority=4, calc=function(a,b,c,d)
			if type(c.mathgteq)==type(function()end) then return c.mathgteq(d(a),d(b)) end
			if c.abs(c.nonRealPart(d(a))) > 1e-14 or c.abs(c.nonRealPart(d(b))) > 1e-14 then return 0 end
			return d(c.re(d(a))>=c.re(d(b))and 1 or 0)
		end},
		['≤'] = { propetry="op", count = 2, priority=4, ppriority=4, calc=function(a,b,c,d)
			if type(c.mathlteq)==type(function()end) then return c.mathlteq(d(a),d(b)) end
			if c.abs(c.nonRealPart(d(a))) > 1e-14 or c.abs(c.nonRealPart(d(b))) > 1e-14 then return 0 end
			return d(c.re(d(a))<=c.re(d(b))and 1 or 0)
		end},
		['&'] = { propetry="op", count = 2, priority=4, ppriority=4, calc=function(a,b,c,d)
			if type(c.mathand)==type(function()end) then return c.mathand(d(a),d(b)) end
			return d(((c.abs(d(a)) > 1e-14) and (c.abs(d(b)) > 1e-14))and 1 or 0)
		end},
		['|'] = { propetry="op", count = 2, priority=4, ppriority=4, calc=function(a,b,c,d)
			if type(c.mathor)==type(function()end) then return c.mathor(d(a),d(b)) end
			return d(((c.abs(d(a)) > 1e-14) or (c.abs(d(b)) > 1e-14))and 1 or 0)
		end},
		['~'] = { propetry="op", count = 1, priority=10, ppriority=10, calc=function(a,c,d)
			if type(c.mathnot)==type(function()end) then return c.mathnot(d(a)) end
			return d((not(c.abs(d(a)) > 1e-14))and 1 or 0)
		end},
}
return p