The state machine has the below specifications
(defparameter *test-machine*
(make-fsm
:alphabet '(a b)
:table '((2 1) (0 2) (1 0))
:initial 0
:accepting '(2)))
The FSM in the function is:
[1]> (fsm-alphabet *test-machine*)
(A B)
[2]> (fsm-initial *test-machine*)
0
[3]> (fsm-accepting *test-machine*)
(1)
The transition of the function is - the element of the alphabet of fsm the state index of the function is the index of the current state in the list of states
below is the function output
[3]> (transition-function *test-machine* 0 'a)
2
[4]> (transition-function *test-machine* 0 'b)
1
[5]> (transition-function *test-machine* 2 'b)
0
the built-in function position will return the index of an element in a list if that element exists. For example, (position '3 '(1 2 0 2 3 5 6)) will return 4.