A reddit thread brought up an apparently interesting question:
Tail recursive functions can trivially be converted into iterative functions. Other one
Is it always possible to write a non-recursive form for every recursive function?
Yes. A simple formal proof is to show that both µ recursion and a non-recursive calculus such as GOTO are both Turing complete. Since all Turing complete calculi are strictly equivalent in their expressive power, all recursive functions can be implemented by the non-recursive Turing-complete calculus.
Unfortunately, I’m unable to find a good, formal definition of GOTO online so here’s one:
A GOTO program is a sequence of commands P executed on a register machine such that P is one of the following:
HALT
, which halts executionr = r + 1
where r
is any registerr = r – 1
where r
is any registerGOTO x
where x
is a labelIF r ≠ 0 GOTO x
where r
is any register and x
is a labelHowever, the conversions between recursive and non-recursive functions isn’t always trivial (except by mindless manual re-implementation of the call stack).
For further information see this answer.