finite state machine

using scheme to represent a finite state machine