3 ms·
The original question is unclear. What is a 'loop' and what is a 'conditional'? Tail-recursive calls (like the linked solution uses, though C compilers usually
by lysium 16y ago
The original question is unclear. What is a 'loop' and what is a 'conditional'?
Tail-recursive calls (like the linked solution uses, though C compilers usually do not implement 'proper' tail calls) or short-cut conditionals might not look like but are still loops or conditionals.
So, why the answer is funny it does not answer the original question.
- seiji 16y agothough C compilers usually do not implement 'proper' tail calls With optimizations turned on, gcc turns a tail recursive function into the equivalent of a for loop.
- danvet 16y ago.. which I've lately found out the hard way: Code of mine randomly crashed and valgrind told me it's due to use of unintiliazed memory. An awful lot of time later (i.e. one valgrind --track-origins=yes run) I know that it's from function foo's stack space. Which contains one local variable which is clearly assigned at the beginning. _Much_ later I find out that the problem is in bar, tail-called by foo. At least now I know that latest gcc can do tail-call optimizations.