Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Recursion Confusion

by sundialsvc4 (Abbot)
on Apr 29, 2013 at 15:21 UTC ( #1031241=note: print w/ replies, xml ) Need Help??


in reply to Recursion Confusion

The key to understanding recursion is to realize where the my variables that are declared within a sub actually live:   “on the stack,” which also contains information needed to return from a subroutine call.   When any subroutine calls itself, directly or indirectly, i.e. “recursion,” each instance of the call has its own set of so-called “local” variables.

Thus, any sub can, within a loop controlled by a local variable, call any other sub, including itself, and it Just Works.™


Comment on Re: Recursion Confusion

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1031241]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2015-07-03 16:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (54 votes), past polls