Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Recursive Subs?
Can someone explain to me what recursive subs do. Mu understanding i
that it is a sub that in effect calls itself. Why would you ever nee this? What woudl be an example of this -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Recursive Subs?
Hi
similar questions was aske prior this day. Here's a repost: Frank ------ one reason is the use for recursive algorithms. e.g. calculation of the factorial (e.g. 5! =1*2*3*4*5): Function fact(i as integer) as long If i = 0 then fact = 1 else fact = i*fact(i-1) end if end function Of course you can achieve this without recursion but this way its 'easier' to read. you may have a look at the following site: http://cse.unl.edu/~dsadofs/Recursio...p?s=algorithms for more information (or just do a google search for 'recursive algorithms') Can someone explain to me what recursive subs do. Mu understanding is that it is a sub that in effect calls itself. Why would you ever need this? What woudl be an example of this? --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Recursive Subs?
They are generally used when you don't know in advance how
big your loop size is and have problems defining an efficient loop structure. For an example, see my posting today delete folder Feb 4 2004 8:55AM There are some problems for which recursion is the more elegant apppoach (e.g. code readability) but "Out of stack space" can be a problem if the stack space is unduly constrained. Kevin Beckham -----Original Message----- Can someone explain to me what recursive subs do. Mu understanding is that it is a sub that in effect calls itself. Why would you ever need this? What woudl be an example of this? --- Message posted from http://www.ExcelForum.com/ . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Recursive Subs?
Recursion is as when a procedure calls itself. It can be an extremely useful
technique, but has to be used with care. The biog advantage is that it allows you to process when you have absolutely no idea how many levels of your particular item will occur, and so if you are processing a data type, and amongst that you find another set of that datatype, you can just branch out of your current processing, process the new item by calling itself, and then pick up where you were at the end. And this can be done a number of times. The best example I have is a VBScript that deletes files from the temp folder. It builds an array of files to delete. It start in the temp directory, and adds to the array. If one of the files is a directory, it recursively calls itself for this new directory, and so on. Thus, I don't have to do any testing on the number of sub-folders, and sub-folders of sub-folders, etc. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "ExcelMonkey " wrote in message ... Can someone explain to me what recursive subs do. Mu understanding is that it is a sub that in effect calls itself. Why would you ever need this? What woudl be an example of this? --- Message posted from http://www.ExcelForum.com/ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Recursive Subs?
Can someone explain to me what recursive subs do.
To define recursion, we must first define recursion... |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Recursive Subs?
;-)
That's an illustration of what can go wrong if the recursive algorithm is poorly designed. loop, infinite - see infinite loop infinite loop - see loop, infinite "Vic Eldridge" wrote in message m... Can someone explain to me what recursive subs do. To define recursion, we must first define recursion... |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Recursive Functions...maybe | Excel Worksheet Functions | |||
How do you write a recursive formula in excel? | Excel Worksheet Functions | |||
recursive formula question | Excel Worksheet Functions | |||
Recursive Functio help | Excel Worksheet Functions | |||
recursive sums | Excel Worksheet Functions |