def simplify_constant(self): terms_counter_analyzer = TermsCounterAnalyzer(self._term_list) terms = terms_counter_analyzer.get_constants() if 0 == len(terms): return self._remove_terms(terms) self.add_term(ConstantBuilder().value( self._get_added_terms_value(terms)).build())
def get_value_constant(self): terms_counter_analyzer = TermsCounterAnalyzer(self._term_list) constants = terms_counter_analyzer.get_constants() if 1 == len(constants): return constants[0].value elif 1 < len(constants): raise NotSimplified else: return 0