| 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) |
| | 79 | D_ = lambda c:c(D_) |
| | 80 | D = lambda :D_ |
| | 81 | |
| | 82 | C = lambda :lambda c:c(lambda Y,c: lambda :Y(lambda F,c_:c(F),c)) |
| | 83 | |
| | 84 | V0 = lambda X,c:c(V0) |
| | 85 | V = lambda:lambda c:c(V0) |