2 ms·
> But some things are so easily expressed as a recursion but require considerable thought to be turned into a loop. Do you have some examples of problem+soluti
by e12e 9y ago
> But some things are so easily expressed as a recursion but require considerable thought to be turned into a loop.
Do you have some examples of problem+solutions where tco works fine (in a language with tco) - but the manual translation is hard(ish)?
I wonder in part after reading the Julia thread on tco - and difficulties with providing guarantees in the general case with tco:
https://github.com/JuliaLang/julia/issues/4964 https://github.com/JuliaLang/julia/issues/4964
- lysium 9y agoUsually, I implement state machines with mutually tail recursive functions. Each function represents one state.
- e12e 9y agoRight. The general rewrite would be a loop with a switch and state functions that returned a state? (i was going to say state functions that called back to a step function, but I guess that'd still build a call stack).