Every finete state machine that does not need to hold state can be represented by a mutual recursive pair (or more) of functions.
You can implement mutual recursion using the built-in and
keyword between functions.
It is also possible to implement it using a higher order function (a function that receives another function).