Exemplo n.º 1
0
     modifier = words.pop(0)
     if not words:
         print 'ERROR: %r requires an expression' % (modifier,)
         continue
 for i,w in enumerate(words):
     if w == ':last':
         if last is None:
             print 'ERROR: no previous expression'
             giveup = True
             break
         else:
             words[i] = '(%s)' % (last,)
 if giveup: continue
 line = ' '.join(words)
 try:
     expr = lambdas.parseline(line, bindings)
 except lambdas.LambdaError, e:
     print 'ERROR: %s' % (e,)
     continue
 if isinstance(expr, tuple):
     bindings[expr[0]] = last = expr[1]
     if modifier == ':repr':
         print repr(last)
 elif modifier == ':repr':
     #print repr(expr)
     # Are there any circumstances in which a non-strict `repr` would be
     # desirable?
     try:
         last = lambdas.evaluate(expr, lambdas.strict_limit)
     except lambdas.LambdaError, e:
         print 'ERROR: %s' % (e,)
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
import sys
sys.path.insert(1, sys.path[0] + '/..')
import lambdas

expr01 = lambdas.parseline("(λx. x x) (λxy.y) 'a")
print str(expr01)
print repr(expr01)
Exemplo n.º 3
0
# -*- coding: utf-8 -*-
import sys
sys.path.insert(1, sys.path[0] + '/..')
import lambdas

expr01 = lambdas.parseline('λxy. x (λz. λy. y)')
print str(expr01)
print repr(expr01)
Exemplo n.º 4
0
# -*- coding: utf-8 -*-
import sys

sys.path.insert(1, sys.path[0] + "/..")
import lambdas

exprStr = "(λx. x x) (λxy.y) 'a"

expr = lambdas.parseline(exprStr)
while expr is not None:
    print str(expr)
    expr = expr.eval()