|
|
|
|
|
|
|
Our program for counting not-equal operators is only one way of accomplishing the task. Another is to design the program using a finite state machine. A finite state machine is an idealized model of a very simple computer. It consists of a set of states and a set of transition rules for changing from one state to another. |
|
|
|
|
|
|
|
|
|
For example, a thermostat is a finite state machine with two states: on and off. And it has just two transition rules: |
|
|
|
|
|
|
|
|
|
If the measured temperature is less than the set temperature, switch from off to on. |
|
|
|
|
|
|
|
|
|
If the measured temperature is more than a degree warmer than the set temperature, switch from on to off. |
|
|
|
|
|
|
|
|
|
Only one transition rule can be valid at a time. |
|
|
|
|
|