Changeset 1688 for lang/unlambda
 Timestamp:
 11/17/07 01:29:33 (9 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

lang/unlambda/impl/in_python/unlambda.py
r1683 r1688 3 3 4 4 # doctest 5 >>> p = parse("``skk").eval() 5 >>> p = parse("``skk").eval() # SKK = I 6 6 >>> p(1) 7 7 1 8 8 9 >>> p = parse("`.a. a").eval()9 >>> p = parse("`.a.b").eval() 10 10 a 11 12 >>> run("`.a`rr") # carriage return 13 <BLANKLINE> 14 a 15 16 >>> run("`vv").func_name # blackhole 17 'V0' 11 18 """ 12 19 … … 29 36 sys.stdout.write(self.c) 30 37 return Dot0 38 39 class R(Node): 40 def eval(self): 41 def R0(X): 42 print 43 return R0 31 44 32 45 class K(Node): … … 54 67 return I0 55 68 69 class V(Node): 70 """blackhole: v(x) == v 71 equivalent to ` ``s``s`kskk ``s``s`kskk""" 72 def eval(self): 73 def V0(X): 74 return V0 75 return V0 76 56 77 def _parse(iter): 57 78 c = iter.next() … … 61 82 "s": lambda: S(), 62 83 "k": lambda: K(), 63 ".": lambda: Dot(iter.next()) 64 }[c]() 84 ".": lambda: Dot(iter.next()), 85 "r": lambda: R(), 86 "v": lambda: V(), 87 }.get(c, lambda: _parse(iter))() 65 88 return result 66 89 … … 68 91 return _parse(list(s).__iter__()) 69 92 93 def run(s): 94 return parse(s).eval() 95 70 96 def _test(): 71 97 import doctest