Show
Ignore:
Timestamp:
11/19/07 01:20:41 (14 months ago)
Author:
nishio
Message:

lang/unlambda/impl/in_python: replace Delay, Void and call/cc with lambda

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/unlambda/impl/in_python/unlambda_lambda.py

    r1761 r1762  
    6969            lambda X:\ 
    7070                lambda:\ 
    71                     (X.__class__ == D)and( 
     71                    (X == D_)and( 
    7272                        c(lambda Y,c:nY(lambda X:c(lambda X,c:X(Y,c)))) 
    7373                    )or( 
     
    7777            ) 
    7878 
    79 class D(Node): 
    80     "delay (special form)" 
    81     def __str__(self): 
    82          return "D" 
    83     def __call__(self, cont): 
    84         return cont(self) 
    85      
    86  
    87 class C(Node): 
    88     "call/cc" 
    89     def __str__(self): 
    90         return "C" 
    91     def __call__(self, cont): 
    92         def C0(Y, cont): 
    93             def C1(func, new_cont): 
    94                 return cont(func) # use old cont 
    95             operator = Y 
    96             operand = C1 
    97             def Apply(): # task 
    98                 return operator(operand, cont) 
    99             return Apply 
    100         return cont(C0) 
    101  
    102 class V(Node): 
    103     """void: v(x) == v 
    104     equivalent to ` ``s``s`kskk ``s``s`kskk""" 
    105     def __str__(self): 
    106         return "V" 
    107     def __call__(self, cont): 
    108         def V0(X, cont): 
    109             return cont(V0) 
    110         return cont(V0) 
     79D_ = lambda c:c(D_) 
     80D = lambda :D_ 
     81 
     82C = lambda :lambda c:c(lambda Y,c: lambda :Y(lambda F,c_:c(F),c)) 
     83 
     84V0 = lambda X,c:c(V0) 
     85V = lambda:lambda c:c(V0) 
    11186 
    11287class K(Node):