Changeset 1936 for lang/unlambda
 Timestamp:
 11/23/07 15:09:09 (8 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

lang/unlambda/impl/in_python/unlambda_oneliner.py
r1932 r1936 23 23 """ 24 24 import sys 25 unlambda = lambda:None 25 26 26 27 # Node 27 28 28 D_ = lambda c:c(D_)29 V=lambda X,c:c(V)29 unlambda.D_ = lambda c:c(unlambda.D_) 30 unlambda.V = lambda X,c:c(unlambda.V) 30 31 31 parse = (lambda Dot, Apply:(lambda s: (lambda f:((lambda g: f(lambda x: g(g)(x))) 32 # Main loop 33 34 unlambda.next = lambda :unlambda.__setattr__( 35 "task", 36 unlambda.task()) or unlambda.task 37 unlambda.init = lambda task: unlambda.__setattr__("task", task) 38 39 from itertools import count, ifilter 40 run = lambda s:\ 41 unlambda.init(lambda:(lambda Dot, Apply:(lambda s: (lambda f:((lambda g: f(lambda x: g(g)(x))) 32 42 (lambda g: f(lambda x: g(g)(x)))))(lambda _parse: lambda iter:{ 33 43 "i": lambda:lambda c:c(lambda X,c:c(X)), 34 "d": lambda: D_,44 "d": lambda:unlambda.D_, 35 45 "c": lambda:lambda c:c(lambda Y,c:lambda:Y(lambda F,c_:c(F),c)), 36 "v": lambda:lambda c:c( V),46 "v": lambda:lambda c:c(unlambda.V), 37 47 "s": lambda:lambda c:c( 38 48 lambda X,c:c( … … 57 67 lambda:nX(lambda X: 58 68 lambda: 59 (X == D_)and(69 (X == unlambda.D_)and( 60 70 c(lambda Y,c:nY(lambda X:c(lambda X,c:X(Y,c)))) 61 71 )or( 62 72 nY(lambda Y:lambda:X(Y, c))))) # apply 63 ) 64 65 # Main loop 66 67 unlambda = lambda:None 68 unlambda.next = lambda :unlambda.__setattr__( 69 "task", 70 unlambda.task()) or unlambda.task 71 72 from itertools import count, ifilter 73 run = lambda s:\ 74 unlambda.__setattr__("task", lambda:parse(s)(lambda f:lambda:None)) or\ 73 )(s)(lambda f:lambda:None)) or\ 75 74 ifilter(lambda x:not(unlambda.next()), count()).next() and None 76 75