I've got an internal state, which has to be updated continuously. Following functional programming, the state is immutable and the loop is implemented using recursion. An example way of how this could be implemented in a hypothetical (C based) language is then:
void RunUpdateLoop(WorldState world)
{
WorldState newWorld = Update(world);
RunUpdateLoop(newWorld);
}
However, this would quickly result in a stack overflow (assuming tail recursion optimization doesn't happen). How can this be implemented in a functional way without resulting in a stack overflow?