Exemplo n.º 1
0
 def build_lambda(word):
     def body(letters):
         if not letters:
             return 'x'
         elif letters[0] == 'A':
             return 'car(' + body(letters[1:]) + ')'
         else:
             return 'cdr(' + body(letters[1:]) + ')'
     return eval('lambda x: ' + body(word)) # Danger
Exemplo n.º 2
0
def _eval(expr):
    """Evaluate an expression in the global environment"""
    from src.eval import eval
    return eval(expr, global_env)