View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_7_] Peter T[_7_] is offline
external usenet poster
 
Posts: 162
Default Recursive To non-Recursive Procedure

"Bruno Campanini" wrote in message
Peter T explained

:
"Bruno Campanini" wrote in message
Peter T formulated the question :
"Bruno Campanini" wrote in message
On the other hand, *why* do you want it to be unrolled?

Why you ask me that?

You seem reluctant to give a reason. Is this homework to find a less
elegant non-recursive alternative as an exercise?

Here's a Google search that'll get you started:
https://www.google.com/search?q=stri...+non-recursive
Really I don't need that.

Why not? I found several potential solutions in a few minutes.
Oh... you are a very clever man, congratulation!
Why don't you read accurately before writing?

I don't need any practical solution, it's only a matter of
principle.
I would be able to convert that particular algorithm into a
non-recursive procedure, but I'm unable to do so.
Then I put here the question.

Have I satisfied your curiosity?


Not really a matter of curiosity, often asking the objective leads to a
different approach the OP might not have considered, particularly when
the reason for the question is not clear. So it's a sort of intellectual
exercise then, right?

Although any approach will end up doing essentially the same thing your
algorithm is not directly convertible as it's designed to be recursive.

Any recursive algorithm is convertible into a non-recursive one...
and vice-versa!


Some recursive routines can be 'converted' to non-recursive using
essentially the same algorithm inside an additional loop. However I don't
see an obvious way that can be done with your particular algorithm. So it
means devising a different approach, or instead of re-inventing the wheel
search as suggested and adapt what best suits the particular objective.

The cost may be a great difficulty, a loss of simplicity, a loss
of efficiency.


Typically no significant difference in efficiency, if anything non-recursive
may be slightly more efficient (in terms of speed) even if less elegant.

Oh... you are a very clever man, congratulation!

Huh, it was a simple search, why the sarcasm, why not try yourself!

Such a simple search that I tried just before you was born!

Why don't you read accurately before writing?

AFAIK I did read accurately before posting. Not sure why you're so
aggressive to people who try to help you.

Not to all people, only to all who:
- didn't understand the question
- doesn't have an idea about the solution.
- doesn't hesitate to spend unuseful words... as it costs nothing!


I don't know what your problem is. I've answered 1000s of question in this
group going back since before MS adopted it, but rarely come across an
attitude like yours.

I thought I understood your question, then your replies to Auric confused
me, I didn't understand why his suggestion wasn't helpful and your
reluctance to give a reason didn't help. Hence I tried to get a better idea
of your overall objective before wasting time on something you didn't want.

I use recursive functions extensively and already knew your algorithm,
though FWIW the particular implementation you posted is inefficient for
Excel with an input of any more than a few letters.

Peter T