Skip to content

Instantly share code, notes, and snippets.

@rcshubhadeep
Created July 21, 2021 17:39
Show Gist options
  • Save rcshubhadeep/c417dba7bda6890582ef53ad7d28e4c4 to your computer and use it in GitHub Desktop.
Save rcshubhadeep/c417dba7bda6890582ef53ad7d28e4c4 to your computer and use it in GitHub Desktop.
Compute the State Machine
func (s *StateMachine) Compute(events []string, printState bool) State {
for _, e := range events {
s.FireEvent(Event(e))
if printState {
fmt.Printf("%s\n", s.PresentState.String())
}
}
return s.PresentState
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment