Ejemplo n.º 1
0
import lazyk
# Mocking: Mx = xx
# SIIx = (Ix)(Ix) = xx
M = lazyk.parse("S(SKK)(SKK)")

# Compose: Cxyz = x(yz)
# x(yz) = S(Kx)yz
# S(Kx) = S(KS)Kx
C = lazyk.parse("S(KS)K")

# if KV = V, KVx = V = Vx
# (K*M)(K*M) = K(M(K*M)) = K(K*M)(K*M)
# so V = (K*M)(K*M) = (CKM)(CKM)

V = lazyk.to_ast([[C, 'K', M], [C, 'K', M]])

tree = V
buf = []
for i in range(50):
    if tree in buf: break
    buf.append(tree)
    tree = lazyk.step(tree)

print buf
Ejemplo n.º 2
0
# test ap.lazy
code = "K(SII(S(K(S(K(S(K(S(SI(K(S(S(KS)K)(S(S(S(KS)K))(SII)(S(S(KS)K)I)))))))K))(S(K(S(SI(K(S(S(KS)K)(S(S(KS)K)(S(S(S(KS)K))(SII)(S(S(KS)K)I))))))))K)))(SII)))"
import lazyk

input_stream = None
# (f input_stream) = output_stream
tree = [[lazyk.parse(code), input_stream], lazyk.Output]

for i in range(100):
    tree = lazyk.step(tree)
Ejemplo n.º 3
0
import lazyk
sample_code = file("primes.txt").read().replace("I", "(SKK)")
tree = lazyk.parse(sample_code)
while tree:
    print tree
    print
    tree = lazyk.step(tree)
Ejemplo n.º 4
0
# test id.lazy
code = "I"
import lazyk

tree = [[lazyk.parse(code), lazyk.Input], lazyk.Output]

for i in range(100):
    tree = lazyk.step(tree)