Rewrite two constants into one constant (in combine_numerics).

parent 7f4097c6
from itertools import combinations from itertools import combinations
from ..node import ExpressionNode as Node, TYPE_OPERATOR, OP_ADD, OP_MUL from ..node import ExpressionNode as Node, ExpressionLeaf as Leaf, \
TYPE_OPERATOR, OP_ADD, OP_MUL
from ..possibilities import Possibility as P from ..possibilities import Possibility as P
from .utils import nary_node from .utils import nary_node
...@@ -110,6 +111,18 @@ def match_combine_polynomes(node, verbose=False): ...@@ -110,6 +111,18 @@ def match_combine_polynomes(node, verbose=False):
return p return p
def combine_numerics(root, args):
"""
Combine two constants to a single constant in an n-ary plus.
Synopsis:
c0 + c1 -> eval(c1 + c2)
"""
c0, c1 = args
return Leaf(c0.value + c1.value)
def combine_polynomes(root, args): def combine_polynomes(root, args):
""" """
Combine two multiplications of any polynome in an n-ary plus. Combine two multiplications of any polynome in an n-ary plus.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment