I just familarized myself with a Turing machine. I'm in the process of making a semi-accurate virtual Turing machine but I ran into a seemingly simple problem that I just know there is a solution for. I researched online but couldn't find anything that satisfied my issue.
How do I make the variable 'l' callable within the function. It must be callable because if I define the initial value of the variable within the function, when the function loops it will reset the value to 0.
Here is my code:
blanktape = []
for x in range(1,251):
x = ' '
blanktape.append(x)
global l
l = 1
non = ' '
head = blanktape[l]
symbols = [3, 'ee', 'x']
def mconfigb():
if head == non:
blanktape[blanktape.index(head)] = 0
l = l + 2
def mconfigc():
if head == non:
blanktape[blanktape.index(head)] = 1
l = l + 2
def turingmachine():
while l < len(blanktape) + 1:
mconfigb()
mconfigc()
return blanktape
print turingmachine()