Last active
April 17, 2017 12:02
-
-
Save MizukiSonoko/6cdf25cee7268cd176309f6516b4b464 to your computer and use it in GitHub Desktop.
RAM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = [0] * 7 | |
pc = 1 | |
def M(i,j): | |
def _m(): | |
r[i] = r[j] | |
return False | |
return _m | |
def J(i,j,k): | |
def _j(): | |
if r[i] == r[j]: | |
global pc | |
pc = k | |
return True | |
return False | |
return _j | |
def S(i): | |
def _s(): | |
r[i] += 1 | |
return False | |
return _s | |
def Z(i): | |
def _z(): | |
r[i] = 0 | |
return False | |
return _z | |
def E(): | |
def _e(): | |
print("=== result ===") | |
for i in range(0,len(r)): | |
print( "{:>3}".format(i), end="|") | |
print() | |
for i in range(0,len(r)): | |
print( "{:>3}".format(r[i]), end="|") | |
print() | |
print("R(0) = ",r[0]) | |
print("==============") | |
return _e | |
def D(): | |
pass | |
if __name__ == "__main__": | |
ins = [] | |
r[1] = 7 | |
r[2] = 3 | |
ins = [ | |
D, | |
M(3,2), | |
J(1,3,6), | |
S(3), | |
S(0), | |
J(0,0,2), | |
E() | |
] | |
while True: | |
if not ins[pc](): | |
pc += 1 | |
if pc == len(ins) - 1: | |
ins[pc]() | |
quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
命令