I am trying to implement a transition function. I have stored the transitions in a list:
def transistion(self, input):
self.currentState = 'q1'
self.delta = "[['q1', '0', 'q2'], ['q1', '1', 'q1']]"
k = ast.literal_eval(self.delta)
delta_list = [[x[0],tuple(x[1:])] for x in k]
print(delta_list)
print(delta_list) # [['q1', ('0', 'q2')], ['q1', ('1', 'q1')]]
I need to:
- search delta_list to see if the self.currentState is a first element in one of the lists
- if the first element was found, check that list and see if the first element of the tuple is equal to input
- if the input value was also found, set self.currentState equal to the second element of the tuple