iDante comments on Types of recursion - Less Wrong

16 Post author: AnthonyC 04 September 2013 05:48PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (16)

You are viewing a single comment's thread. Show more comments above.

Comment author: iDante 04 September 2013 11:40:34PM *  4 points [-]

The first is head recursive. If it were written in opposite order (in NY, on the street, at the house, the car ...) it would be tail recursive and would be very easy to parse. Once we've found NY we can forget that we're there and reuse our stack space to find the street, etc. I think this is why it's so much easier than the second, which is neither head nor tail recursive and so requires a stack frame for each level.