while 1 do --[[ ... ]]-- end
or
function something() --[[ ... ]]-- something() end
Posted 05 December 2012 - 10:58 AM
while 1 do --[[ ... ]]-- end
function something() --[[ ... ]]-- something() end
Posted 05 December 2012 - 08:02 PM
Posted 05 December 2012 - 10:08 PM
while 1. The recursive one will eventually give you a stack overflow.
Posted 06 December 2012 - 07:36 PM
Posted 06 December 2012 - 08:06 PM
Even if program flow is interrupted before the stack fills up, the recursive one is slower because of the time spent during setting up the stack and stuff for calling/returning from the function.
On the other hand writing non-recursive code for solving some problems can be a pain, e.g Towers of Hanoi; in which recursive approach is preferred.
Source: textbook
Posted 06 December 2012 - 10:38 PM
Posted 21 December 2012 - 06:40 PM
Posted 25 December 2012 - 04:45 PM
Posted 30 December 2012 - 01:19 PM
0 members, 1 guests, 0 anonymous users