mod all ini_step in fraction
This commit is contained in:
parent
20c9c20836
commit
cba821660a
|
@ -174,7 +174,7 @@ class Fraction(Explicable):
|
||||||
|
|
||||||
exp = Expression([self._num, coef1, op.mul, self._denom, coef1, op.mul, op.div, number._num, coef2, op.mul, number._denom, coef2, op.mul, op.div,op.add])
|
exp = Expression([self._num, coef1, op.mul, self._denom, coef1, op.mul, op.div, number._num, coef2, op.mul, number._denom, coef2, op.mul, op.div,op.add])
|
||||||
|
|
||||||
ini_step = Expression(self.postfix_tokens) + Expression(number.postfix_tokens)
|
ini_step = Expression(self.postfix_tokens + number.postfix_tokens + [op.add])
|
||||||
ans = exp.simplify()
|
ans = exp.simplify()
|
||||||
ans.steps = [ini_step] + ans.steps
|
ans.steps = [ini_step] + ans.steps
|
||||||
return ans
|
return ans
|
||||||
|
@ -221,7 +221,7 @@ class Fraction(Explicable):
|
||||||
|
|
||||||
exp = Expression([self._num, coef1, op.mul, self._denom, coef1, op.mul, op.div, number._num, coef2, op.mul, number._denom, coef2, op.mul, op.div,op.sub])
|
exp = Expression([self._num, coef1, op.mul, self._denom, coef1, op.mul, op.div, number._num, coef2, op.mul, number._denom, coef2, op.mul, op.div,op.sub])
|
||||||
|
|
||||||
ini_step = Expression(self.postfix_tokens) - Expression(number.postfix_tokens)
|
ini_step = Expression(self.postfix_tokens + number.postfix_tokens + [op.sub])
|
||||||
ans = exp.simplify()
|
ans = exp.simplify()
|
||||||
ans.steps = [ini_step] + ans.steps
|
ans.steps = [ini_step] + ans.steps
|
||||||
return ans
|
return ans
|
||||||
|
@ -298,7 +298,7 @@ class Fraction(Explicable):
|
||||||
denom = [self._denom]
|
denom = [self._denom]
|
||||||
|
|
||||||
exp = Expression(num + denom + [op.div])
|
exp = Expression(num + denom + [op.div])
|
||||||
ini_step = Expression(self.postfix_tokens) * Expression([other])
|
ini_step = Expression(self.postfix_tokens + [other, op.mul])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
number = self.convert2fraction(other)
|
number = self.convert2fraction(other)
|
||||||
|
@ -322,7 +322,7 @@ class Fraction(Explicable):
|
||||||
|
|
||||||
exp = Expression(num1 + num2 + [ op.mul] + denom1 + denom2 + [op.mul, op.div])
|
exp = Expression(num1 + num2 + [ op.mul] + denom1 + denom2 + [op.mul, op.div])
|
||||||
|
|
||||||
ini_step = Expression(self.postfix_tokens) * Expression(number.postfix_tokens)
|
ini_step = Expression(self.postfix_tokens + number.postfix_tokens + [op.mul])
|
||||||
ans = exp.simplify()
|
ans = exp.simplify()
|
||||||
ans.steps = [ini_step] + ans.steps
|
ans.steps = [ini_step] + ans.steps
|
||||||
return ans
|
return ans
|
||||||
|
@ -354,7 +354,7 @@ class Fraction(Explicable):
|
||||||
|
|
||||||
number = self.convert2fraction(other)
|
number = self.convert2fraction(other)
|
||||||
|
|
||||||
ini_step = Expression(self.postfix_tokens) / Expression(number.postfix_tokens)
|
ini_step = Expression(self.postfix_tokens + number.postfix_tokens + [op.div])
|
||||||
|
|
||||||
number = Fraction(number._denom, number._num)
|
number = Fraction(number._denom, number._num)
|
||||||
ans = self * number
|
ans = self * number
|
||||||
|
@ -398,7 +398,7 @@ class Fraction(Explicable):
|
||||||
elif power == 1:
|
elif power == 1:
|
||||||
return copy(self)
|
return copy(self)
|
||||||
else:
|
else:
|
||||||
ini_step = Expression(self.postfix_tokens) ** power
|
ini_step = Expression(self.postfix_tokens + [power, op.pw])
|
||||||
exp = Expression([self._num, power, op.pw, self._denom, power, op.pw, op.div])
|
exp = Expression([self._num, power, op.pw, self._denom, power, op.pw, op.div])
|
||||||
|
|
||||||
ans = exp.simplify()
|
ans = exp.simplify()
|
||||||
|
|
Loading…
Reference in New Issue