Posting a stack overflow question on stackoverflow.com, how amusing :-)
I\'m running some recursive Ruby code and I get the: \"Stack level too deep (SystemStac
If you are sure that you do not have an Infinite recursion situation then your algorythm is pobably not suited for Ruby to execute it in a recirsive manner. Converting an algorythm from recursion to different kind of stack is pretty easy and I suggest you try that. Here is how you can do it.
def recursive(params)
if some_conditions(params)
recursive(update_params(params))
end
end
recursive(starting_params)
will transform into
stack = [starting_params]
while !stack.empty?
current_params = stack.delete_at(0)
if some_conditions(current_params)
stack << update_params(current_params)
end
end