Created
July 21, 2021 17:39
-
-
Save rcshubhadeep/c417dba7bda6890582ef53ad7d28e4c4 to your computer and use it in GitHub Desktop.
Compute the State Machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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