function LinearValue.ToBaseValue(G)return G._constructor(unpack(G._values))end local function G(G)return function(z,o)if LinearValue.isLinear(z)and LinearValue.isLinear(o)then assert(z._constructor==o._constructor,"\097 \105\115 \110\111\116 \116\104\101 \115\097\109\101 \116\121\112\101 \111\102 \108\105\110\101\097\114\086\097\108\117\101 \097\115 \098")local a={}for C=1,#z._values,1 do a[C]=G(z._values[C],o._values[C])end return LinearValue.new(z._constructor,a)elseif LinearValue.isLinear(z)then if type(o)=="\110\117\109\098\101\114"then local a={}for C=1,#z._values,1 do a[C]=G(z._values[C],o)end return LinearValue.new(z._constructor,a)else error("\066\097\100 \116\121\112\101 \040\098\041")end elseif LinearValue.isLinear(o)then if type(z)=="\110\117\109\098\101\114"then local a={}for C=1,#o._values,1 do a[C]=G(z,o._values[C])end return LinearValue.new(o._constructor,a)else error("\066\097\100 \116\121\112\101 \040\097\041")end else error("\078\101\105\116\104\101\114 \118\097\108\117\101 \105\115 \097 \108\105\110\101\097\114\086\097\108\117\101")end end end

function LinearValue:ToBaseValue()
	return self._constructor(unpack(self._values))
end

local function operation(func)
	return function(a, b)
		if LinearValue.isLinear(a) and LinearValue.isLinear(b) then
			assert(a._constructor == b._constructor, "a is not the same type of linearValue as b")

			local values = {}
			for i=1, #a._values do
				values[i] = func(a._values[i], b._values[i])
			end
			return LinearValue.new(a._constructor, values)
		elseif LinearValue.isLinear(a) then
			if type(b) == "number" then
				local values = {}
				for i=1, #a._values do
					values[i] = func(a._values[i], b)
				end
				return LinearValue.new(a._constructor, values)
			else
				error("Bad type (b)")
			end
		elseif LinearValue.isLinear(b) then
			if type(a) == "number" then
				local values = {}
				for i=1, #b._values do
					values[i] = func(a, b._values[i])
				end
				return LinearValue.new(b._constructor, values)
			else
				error("Bad type (a)")
			end
		else
			error("Neither value is a linearValue")
		end
	end
end
