Subj : Re: Are recursive functions ever needed? To : comp.programming From : John Date : Sat Oct 01 2005 09:30 am "Tatu Portin" wrote in message news:S6v%e.208$nZ1.35@read3.inet.fi... > Are recursive functions ever needed, i.e. cannot you just replace them > with iterative clauses? > > Example: > > b = func (func (func (a))) > > compared to: > > b = a; > for (i = 0; i < 3; i++) > { > b = func (b); > } Hi Tatu, I suppose you can do that when you know the depth of the calls while your programming. But what if you are building something where you don't know the node depth? Which is almost always. I have seen loops when a recursive function is called for. But, in my experience, they quickly become convoluted where as the recursion is simplistic. When ever I've seen it done, it has been a bug filled mess and a maintenance nightmare. I do understand some people just can't get their head around it. I know a programmer who is highly regarded by his peers and clients .. but just doesn't get it ... I thought he was joking when he first told me. If you don't get it, I would encourage you to put what ever time it takes for you to understand this concept and understand when it should and shouldn't be used. That's my 2 cents. Good luck, John .