|
|
|
|
|
by SomeStupidPoint
3174 days ago
|
|
Isn't there an actual distinction here -- induction versus co-induction? I would argue that a loop constructs an answer, while recursion deconstructs input. There's a duality, so you can port algorithms between the two models, but there is an actual distinction. |
|
For one thing, all loops can be trivially unrolled into a tail-recursive function that most languages will trivially transform back into a loop. Clearly these transforms have no bearing on the nature of the computation.
If asked such a question, I’d probably just use goto. (Bonus points if candidates use a goto on one part of one question I ask, since it saves a minute or two of whiteboard cut and paste, BTW).