remove trailing spaces
This commit is contained in:
@@ -22,7 +22,7 @@ class Fake_int(int, Explicable):
|
||||
self.steps = []
|
||||
def simplify(self):
|
||||
return Fake_int(self._val)
|
||||
|
||||
|
||||
|
||||
class Expression(Explicable):
|
||||
"""A calculus expression. Today it can andle only expression with numbers later it will be able to manipulate unknown"""
|
||||
@@ -88,7 +88,7 @@ class Expression(Explicable):
|
||||
expression = object.__new__(cls)
|
||||
|
||||
if type(exp) == str:
|
||||
expression.postfix_tokens = str2tokens(exp)
|
||||
expression.postfix_tokens = str2tokens(exp)
|
||||
|
||||
elif type(exp) == list:
|
||||
# Ici on ne peut convertir les "+" en opérateur que s'ils sont d'arité 2.
|
||||
@@ -96,7 +96,7 @@ class Expression(Explicable):
|
||||
expression.postfix_tokens = flatten_list([tok.postfix_tokens if Expression.isExpression(tok) else tok for tok in exp_mod_op])
|
||||
|
||||
elif type(exp) == Expression:
|
||||
return exp
|
||||
return exp
|
||||
|
||||
elif isNumerand(exp):
|
||||
expression.postfix_tokens = [exp]
|
||||
@@ -156,16 +156,16 @@ class Expression(Explicable):
|
||||
tokenList = self.postfix_tokens.copy()
|
||||
tmpTokenList = []
|
||||
|
||||
while len(tokenList) > 2:
|
||||
# on va chercher les motifs du genre A B +, quand l'operateur est d'arité 2, pour les calculer
|
||||
while len(tokenList) > 2:
|
||||
# on va chercher les motifs du genre A B +, quand l'operateur est d'arité 2, pour les calculer
|
||||
if isNumerand(tokenList[0]) and isNumerand(tokenList[1]) \
|
||||
and isOperator(tokenList[2]) and tokenList[2].arity == 2 :
|
||||
|
||||
|
||||
# S'il y a une opération à faire
|
||||
op1 = tokenList[0]
|
||||
op2 = tokenList[1]
|
||||
operator = tokenList[2]
|
||||
|
||||
|
||||
res = operator(op1, op2)
|
||||
|
||||
tmpTokenList.append(res)
|
||||
@@ -176,7 +176,7 @@ class Expression(Explicable):
|
||||
# Et les motifs du gens A -, quand l'operateur est d'arité 1
|
||||
elif isNumerand(tokenList[0]) \
|
||||
and isOperator(tokenList[1]) and tokenList[1].arity == 1:
|
||||
|
||||
|
||||
# S'il y a une opération à faire
|
||||
op1 = tokenList[0]
|
||||
operator = tokenList[1]
|
||||
@@ -261,7 +261,7 @@ class Expression(Explicable):
|
||||
return Expression(self.postfix_tokens + other + [operator])
|
||||
else:
|
||||
return Expression(self.postfix_tokens + [other] + [operator])
|
||||
|
||||
|
||||
def roperate(self, other, operator):
|
||||
if type(other) == Expression:
|
||||
return Expression(other.postfix_tokens + self.postfix_tokens + [operator])
|
||||
@@ -336,7 +336,7 @@ class Expression(Explicable):
|
||||
>>> c = a / b
|
||||
>>> print(c.postfix_tokens)
|
||||
[1, 2, '+', 3, 4, '+', '/']
|
||||
>>>
|
||||
>>>
|
||||
"""
|
||||
return self.operate(other, op.div)
|
||||
|
||||
@@ -351,7 +351,7 @@ class Expression(Explicable):
|
||||
|
||||
def __neg__(self):
|
||||
return Expression(self.postfix_tokens + [op.sub1])
|
||||
|
||||
|
||||
|
||||
def untest(exp):
|
||||
a = Expression(exp)
|
||||
@@ -376,7 +376,7 @@ if __name__ == '__main__':
|
||||
# print(i)
|
||||
|
||||
#print(type(Ar))
|
||||
|
||||
|
||||
|
||||
#print('\n-----------')
|
||||
#A = Expression("-6 / 3 + 10 / -5")
|
||||
@@ -396,4 +396,4 @@ if __name__ == '__main__':
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
# cursor: 16 del
|
||||
|
||||
Reference in New Issue
Block a user