|
@@ -1,6 +1,7 @@
|
|
|
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):
|
|
|
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.
|