recursion

nkuipers nkuipers at uvic.ca
Thu Jan 30 15:12:11 CST 2003


Hello all,

In Java class today the instructor introduced recursion.  He coded up a very 
simple program expressed in pseudocode as follows:

method printme with arg int
if int not equal to 0 { printme (int-1) }
print int

The fact that this program with initial input of 7 printed 1 through 7 in that 
order blew my mind, and although I came to a recognition of what was 
happening, I can't say I truly understand it and certainly in a more complex 
recursion I'd be hooped.  Now, of the three concepts he told us we need to 
understand (base case, progress), the third was the oddest, and, he said, the 
trickiest, and that was simply that you have to believe it will work.  He also 
said that it's critical to sit down in front of a computer and play with stuff 
like this.  Since Perl is more native to my mind, I'd like to do my conceptual 
playing in Perl, and then I expect it'll be fairly easy to implement these 
concepts in Java.

My question then is what is the best way to approach recursion in general, 
with a slant to Perl.  Hints on good explanatory references?  Examples?  
Mindsets?  Anything appreciated.  I've also done a supersearch at perlmonks 
and am scanning the nodes returned.

Thanks,

Nathanael 




More information about the Victoria-pm mailing list