Is there a way to use mutual recursion to create a state machine using existing states.
fun oneElse f xs =
case xs of
1::xs' => f xs'
| [] => true
| _ => false;
fun twoElse xs =
case xs of
2::xs' => oneElse twoElse xs'
| [] => false
| _ => false
val oneTwo = oneElse twoElse [1,2,1,2];
This is what I have so far, but what I would like is where the higher order function takes these generic (one doesn't know about the next) states.
fun oneElse f xs = ...
fun twoElse f xs = ...
val oneTwo = oneElse (twoElse (oneElse headache) ) xs