Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Recursion of Recursion of Recursion....of RecusionX (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: Help - Character code for Delta(Triangle)
Next thread: Help please. Why is "Item = nil"?


RB Database   -   tom.russell transport.alstom.com
  Recursion of Recursion of Recursion....of RecusionX   -   Chuck Pelto
   Re: Recursion of Recursion of Recursion....of RecusionX   -   Joseph J. Strout
   Re: Recursion of Recursion of Recursion....of RecusionX   -   Chuck Pelto
    Re: Recursion of Recursion of Recursion....of RecusionX   -   Sean Arney
     Re: Recursion of Recursion of Recursion....of RecusionX   -   Chuck Pelto
      Re: Recursion of Recursion of Recursion....of RecusionX   -   Sean Arney
       Re: Recursion of Recursion of Recursion....of RecusionX   -   Chuck Pelto
       Re: Recursion of Recursion of Recursion....of RecusionX   -   Phil M
       Re: Recursion of Recursion of Recursion....of RecusionX   -   Phil M
       Re: Recursion of Recursion of Recursion....of RecusionX   -   Chuck Pelto
       Re: Recursion of Recursion of Recursion....of RecusionX   -   Charles Yeomans
       Re: Recursion of Recursion of Recursion....of RecusionX   -   Phil M
   Re: Recursion of Recursion of Recursion....of RecusionX   -   Chuck Pelto
   Re: Recursion of Recursion of Recursion....of RecusionX   -   Joseph J. Strout
   Re: Recursion of Recursion of Recursion....of RecusionX   -   Charles Yeomans
   Re: Recursion of Recursion of Recursion....of RecusionX   -   Chuck Pelto
   Re: Recursion of Recursion of Recursion....of RecusionX   -   Joseph J. Strout
    Matt Neuberg's book, HQX files, and Windows RB   -   Barry Traver
   Re: Matt Neuberg's book, HQX files, and Windows RB   -   Joseph J. Strout

Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 18:40 (Thu, 2 Feb 2006 10:40:18 -0700)
From: Chuck Pelto
Has anyone come up with a method to do recursions, when the number of
recursive levels is not known in the first place?

Regards,

Chuck
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 18:40 (Thu, 2 Feb 2006 10:40:40 -0700)
From: Joseph J. Strout
At 10:40 AM -0700 2/2/06, Chuck Pelto wrote:

>Has anyone come up with a method to do recursions, when the number
>of recursive levels is not known in the first place?

Well, sure -- most recursive algorithms are that way. What specific
problem did you have in mind?

Best,
- Joe

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 18:58 (Thu, 2 Feb 2006 10:58:09 -0700)
From: Chuck Pelto

On Feb 2, 2006, at 10:40 AM, Joseph J. Strout wrote:

> At 10:40 AM -0700 2/2/06, Chuck Pelto wrote:
>
>> Has anyone come up with a method to do recursions, when the number
>> of recursive levels is not known in the first place?
>
> Well, sure -- most recursive algorithms are that way. What
> specific problem did you have in mind?

Most recurive algorithms I've seen are arbitrary in their number of
recursive levels.

Where is an example of one that is open-ended?

Regards,

Chuck
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:02 (Thu, 02 Feb 2006 12:02:11 -0600)
From: Sean Arney
>>> Has anyone come up with a method to do recursions, when the number
>>> of recursive levels is not known in the first place?
>>
>> Well, sure -- most recursive algorithms are that way. What
>> specific problem did you have in mind?

When I do something like this it runs until whatever it needs to accomplish
is finished or some failure condition is met.

An example that comes to mind is an algorithm to optimize a machine path
given a set of coordinates.

So once its done (all the points have been accounted for) it exits the loop.

HTH,

-seanA

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:07 (Thu, 2 Feb 2006 11:07:41 -0700)
From: Chuck Pelto

On Feb 2, 2006, at 11:02 AM, Sean Arney wrote:

> So once its done (all the points have been accounted for) it exits
> the loop.

I'm talking about loops within loops within loops within X loops.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:24 (Thu, 02 Feb 2006 12:24:38 -0600)
From: Sean Arney
>> So once its done (all the points have been accounted for) it exits
>> the loop.
>
> I'm talking about loops within loops within loops within X loops.
>

So am I, whats different about your example?

-seanA

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:39 (Thu, 2 Feb 2006 11:39:53 -0700)
From: Chuck Pelto

On Feb 2, 2006, at 11:24 AM, Sean Arney wrote:

>>> So once its done (all the points have been accounted for) it exits
>>> the loop.
>>
>> I'm talking about loops within loops within loops within X loops.
>>
> So am I, whats different about your example?

The difference is I don't HAVE an example.

I'm looking for one.

Can you point one out to me?

Regards,

Chuck
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:48 (Thu, 2 Feb 2006 10:48:23 -0800)
From: Phil M
On Feb 2, 2006, at 10:39 AM, Chuck Pelto wrote:

> On Feb 2, 2006, at 11:24 AM, Sean Arney wrote:
>
>>>> So once its done (all the points have been accounted for) it exits
>>>> the loop.
>>>
>>> I'm talking about loops within loops within loops within X loops.
>>>
>> So am I, whats different about your example?
>
> The difference is I don't HAVE an example.
>
> I'm looking for one.
>
> Can you point one out to me?

Here is a very simple one:

Function PowerTo(x As Integer, n As Integer) As Integer
If (n <= 1) Then Return 1
Return x * PowerTo(x, n - 1)
End Function

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:50 (Thu, 2 Feb 2006 10:50:33 -0800)
From: Phil M
On Feb 2, 2006, at 10:48 AM, Phil M wrote:

> Here is a very simple one:
>
> Function PowerTo(x As Integer, n As Integer) As Integer
> If (n <= 1) Then Return 1
> Return x * PowerTo(x, n - 1)
> End Function

Sorry, that should be:

Function PowerTo(x As Integer, n As Integer) As Integer
If (n <= 0) Then
Return 1
Elseif (n = 1) Then
Return x
Else
Return x * PowerTo(x, n - 1)
End If
End Function

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:55 (Thu, 2 Feb 2006 11:55:30 -0700)
From: Chuck Pelto

On Feb 2, 2006, at 11:48 AM, Phil M wrote:

> Here is a very simple one:
>
> Function PowerTo(x As Integer, n As Integer) As Integer
> If (n <= 1) Then Return 1
> Return x * PowerTo(x, n - 1)
> End Function

So, by way of my described situation, what are X and N supposed to
be? Besides integers?

Is X the number of levels? Or is N? And which is the data?

Regards,

Chuck
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:59 (Thu, 2 Feb 2006 13:59:09 -0500)
From: Charles Yeomans

On Feb 2, 2006, at 1:39 PM, Chuck Pelto wrote:

>
> On Feb 2, 2006, at 11:24 AM, Sean Arney wrote:
>
>>>> So once its done (all the points have been accounted for) it exits
>>>> the loop.
>>>
>>> I'm talking about loops within loops within loops within X loops.
>>>
>> So am I, whats different about your example?

Sub BuildListOfFiles(parent as FolderItem, theList() as FolderItem)
For i as Integer = 1 to startingDirectory.Count
If parent.TrueChild(i).Directory then
BuildListOfFiles parent.TrueChild(i), theList
Else
theList.Append parent.TrueChild(i)
End if
End Sub

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 20:12 (Thu, 2 Feb 2006 11:12:30 -0800)
From: Phil M
On Feb 2, 2006, at 10:55 AM, Chuck Pelto wrote:

>> Here is a very simple one:
>>
>> Function PowerTo(x As Integer, n As Integer) As Integer
>> If (n <= 1) Then Return 1
>> Return x * PowerTo(x, n - 1)
>> End Function
>
> So, by way of my described situation, what are X and N supposed to
> be? Besides integers?
>
> Is X the number of levels? Or is N? And which is the data?

X is the data and N is the number of levels. It is a hand-coded
power function, and not very fast, but used to illustrate the point.

For example if you call PowerTo(2, 4), the method is called 4 times
(once by you and three times recursively) and returns the value of
16. It continues to call deeper and deeper until (n = 1) and then it
starts backing out of the stack until it returns from the function
you initially called.

Google for "Recursion" as it is a very common topic for programming
lectures. And here is the Wikipedia link:

http://en.wikipedia.org/wiki/Recursion

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:06 (Thu, 2 Feb 2006 11:06:28 -0700)
From: Chuck Pelto

On Feb 2, 2006, at 10:40 AM, Joseph J. Strout wrote:

>> Has anyone come up with a method to do recursions, when the number
>> of recursive levels is not known in the first place?
>
> Well, sure -- most recursive algorithms are that way. What
> specific problem did you have in mind?

By way of example.

Say I have an SQLSelect cursor pointing to a selection of records
from a table. The data has been sorted.

THIS selection has two fields in it. I want to build a contextual
menu on the fly. The first field is the primary menu item. Any data
in the second field is to be used to make a submenu of the primary
menu item.

However, the next time I call this method, the cursor may have three
fields. Any information in the third field would be a submenu of the
items in the second field.

The time after that, there could be five fields in the cursor. Any
information in the fourth and fifth fields would be submenu items of
the level above that field.

Do you savvy?

Regards,

Chuck
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 19:54 (Thu, 2 Feb 2006 11:54:16 -0700)
From: Joseph J. Strout
At 10:58 AM -0700 2/2/06, Chuck Pelto wrote:

>Most recurive algorithms I've seen are arbitrary in their number of
>recursive levels.

I've rarely seen one like that -- the only one I can think of is a
game search function, where you want to limit the depth so it doesn't
sit there thinking forever. Most recursive algorithms continue
recursing until their work is done.

>Where is an example of one that is open-ended?

Pretty much anywhere, but here, I'll make one up: it searches the
contents of a folder, recursively, until it finds the file "foo.bar":

Function FindFoo(dir as FolderItem) As FolderItem
for i as Integer = dir.Count DownTo 1
Dim f As FolderItem = dir.TrueItem( i )
if f.Name = "foo.bar" then return f // found it!
if f.Directory then
f = FindFoo(f) // (here's the recursion)
if f <> nil then return f // (here we back out once we have an answer)
end if
next
End Function

I'm just typing this into email, so it may contain a typo or two, but
that's the basic idea.

HTH,
- Joe

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 02.02.06 20:09 (Thu, 2 Feb 2006 14:09:30 -0500)
From: Charles Yeomans

On Feb 2, 2006, at 1:54 PM, Joseph J. Strout wrote:

> At 10:58 AM -0700 2/2/06, Chuck Pelto wrote:
>
>> Most recurive algorithms I've seen are arbitrary in their number of
>> recursive levels.
>
> I've rarely seen one like that -- the only one I can think of is a
> game search function, where you want to limit the depth so it doesn't
> sit there thinking forever. Most recursive algorithms continue
> recursing until their work is done.

Now that you put it this way, the IntroSort code in my SortLibrary uses
bounded recursion.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 03.02.06 17:26 (Fri, 3 Feb 2006 09:26:58 -0700)
From: Chuck Pelto

On Feb 2, 2006, at 11:54 AM, Joseph J. Strout wrote:

> Function FindFoo(dir as FolderItem) As FolderItem
> for i as Integer = dir.Count DownTo 1
> Dim f As FolderItem = dir.TrueItem( i )
> if f.Name = "foo.bar" then return f // found it!
> if f.Directory then
> f = FindFoo(f) // (here's the recursion)
> if f <> nil then return f // (here we back out once we
> have an answer)
> end if
> next
> End Function

Thanks Joseph. This helps quite a bit.

> I'm just typing this into email, so it may contain a typo or two,
> but that's the basic idea.

Yeah. I think you dropped some end ifs.

Thanks, again....

Chuck
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Recursion of Recursion of Recursion....of RecusionX
Date: 03.02.06 17:44 (Fri, 3 Feb 2006 09:44:01 -0700)
From: Joseph J. Strout
At 9:26 AM -0700 2/3/06, Chuck Pelto wrote:

>>Function FindFoo(dir as FolderItem) As FolderItem
>> for i as Integer = dir.Count DownTo 1
>> Dim f As FolderItem = dir.TrueItem( i )
>> if f.Name = "foo.bar" then return f // found it!
>> if f.Directory then
>> f = FindFoo(f) // (here's the recursion)
>> if f <> nil then return f // (here we back out once we
>>have an answer)
>> end if
>> next
>>End Function
>
>Thanks Joseph. This helps quite a bit.

I'm glad I could help.

>>I'm just typing this into email, so it may contain a typo or two,
>>but that's the basic idea.
>
>Yeah. I think you dropped some end ifs.

Hmm, no, I don't think so. Perhaps you're not familiar with the
single-line "if" statement?

Best,
- Joe