Hacker News new | ask | show | jobs
by paradoxparalax 2697 days ago
Once I encountered this curious recursion:'

Here sounds infinite loop maybe, but it should finishing calling each other (a calling b that calls a that calls b again...infinite...)

But when there is a Top maximum Parent that is the top of the parent child pyramid (like a html Body "div", I mean, the one that contains all others") It should stop...well

def a

self.insert //something to make it child of the parent, like a html structure maybe

b //call the second method, the b method below

end

def b

self.insert //same here, same logic//

a //call the first method, the a method above

end

thisHtmlDiv.a //crazy example

So the subject on which you call the method will be added in all the hierarchy chain of the parent child pyramid.

1 comments

This is called mutual recursion. Interpretors rely on it heavily.
Thank you very much , sincerely, jeromebaek. This is the real nice spirit of Hackernwes, and you are one of the heroes who help pass the good Knowledge. Thank you very much, buddy.

Cheers!