Example #1
0
 def evaluate_old(self, values):
     result = self.phrase
     while has_sub_function(result):
         temp = get_sub_function(result, 'all')
         result = result[:temp[1]]\
         + '`' + str(Function(temp[0]).evaluate(values))\
         + '~' + result[temp[2]+1:]
     result = replace_variables(result, {'`':'(', '~':')'})
     result = eval(replace_variables(result, values))
     return result
Example #2
0
 def __init__(self, phrase = ''):
     self.phrase = make_friendly(phrase)
     self.phrase_length = len(phrase)
     self.signed_terms = get_terms(self.phrase)
     self.terms = [i[1:] for i in self.signed_terms]
     self.variables = {}
     self.ordered_variables = []
     for i in get_variables(self.phrase):
         phrase = 'self.'+i+'=0'
         exec(phrase)
         self.variables.update({i:'self.'+i})
         if not ('self.'+i) in self.ordered_variables:
             self.ordered_variables.append('self.'+i)
     self.self_phrase = replace_variables(self.phrase, self.variables)