Re: Is this recursion?




The recursive step is the "reversal(aWord,position-1)" call.

The base case is position equal to 0, which is handled differently from
non-zero. Specifically, the recursive step is not done in the base case.

They have the correct relation to each other, if position is initially
non-negative. The recursive step then uses a function of position,
position-1, that ensures that it must reach the base case, position==0.

Incidentally, you should look at your handling for empty strings.

Patricia

Thanks Patricia and Gordon,

I thought my base case was there but U wasn't confident about my
reasoning until you two explained it a bit to me.

Patricia, I learned from Gordon in another program that strings were
compared using ".equal" and not "==". I'm afraid I will never forget
this even after I am 101 years old . . . with senility. It's been
burned into my brain, permanently. :p)

In the simplified example code I provided, the empty string does not
exist since the program initialized before calling the recursive
method. I understand that calling a recursive method when a negative
number condition exists is not a happy event. In my current code that
is not shown here, I do check for the empty string condition before
proceeding.

Thanks very much for your analysis, Patricia and Gordon, btw. Much
appreciated!



.



Relevant Pages

  • Re: $_REQUEST
    ... Calling the first URL everything works fine, calling the second I get an ... error saying 'VAR2' is not in the array $_REQUEST. ... want my function to return an empty string. ... > Kind Regards ...
    (alt.php)
  • Re: [Global.asax] function Server.MapPath not available ?
    ... you are implicitly calling the method or accessing the property from the Page object. ... Instead of calling the MapPath method, you can call the Context.MapPath method. ... my .aspx page folder is here ... both return an empty string ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Help with DataTable.Rows Reference
    ... If your "Test" function would still work with an empty string then you can ... I have a Public Function which requires 2 parameters as follows... ... > Prior to calling this function, I fill a datasetwith an undetermined ... > amount of records, and then use a datatableto reference the rows of the ...
    (microsoft.public.dotnet.general)
  • VB6 empty string -> to a .net - how to
    ... How does one send an empty string from vb6 when calling a vb.net function through interop? ...
    (microsoft.public.dotnet.framework.interop)