Change ** to ^ and mod test in render
This commit is contained in:
parent
65ba8f3f04
commit
047fb903e7
10
formal.py
10
formal.py
@ -35,7 +35,7 @@ class FormalExp(object):
|
||||
:returns: a_n
|
||||
|
||||
"""
|
||||
pattern = "\w\*\*(\d*)"
|
||||
pattern = "\w\^(\d*)"
|
||||
finder = re.compile(pattern)
|
||||
power = {}
|
||||
for (k,v) in self._coef.items():
|
||||
@ -135,12 +135,12 @@ class FormalExp(object):
|
||||
|
||||
def __str__(self):
|
||||
return " + ".join([str(v) + str(k) for k,v in self._coef.items()])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
fe1 = FormalExp({"x": 1, "":2})
|
||||
print(fe1)
|
||||
fe2 = FormalExp({"x**12": 5, "":2})
|
||||
print(fe2)
|
||||
print(fe1.get_postfix())
|
||||
fe2 = FormalExp({"x^12": 5, "":2})
|
||||
print(fe2.get_postfix())
|
||||
fe3 = fe1 * fe2
|
||||
for s in fe3:
|
||||
print(s)
|
||||
|
@ -243,13 +243,12 @@ tex_render = Render(tex_infix, tex_postfix, tex_other, type_render = tex_type_re
|
||||
|
||||
if __name__ == '__main__':
|
||||
exp = [2, 5, '+', 1, '-', 3, 4, '*', '/']
|
||||
print(txt(exp))
|
||||
print(txt_render(exp))
|
||||
exp = [2, 5, '+', 1, '-', 3, 4, '*', '/', 3, '+']
|
||||
print(tex(exp))
|
||||
print(tex_render(exp))
|
||||
exp = [2, 5, '+', 1, '-', 3, 4, '*', '/', 3, '+']
|
||||
print(post2in_fix(exp))
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue
Block a user