Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: recursion basics

by aaron_baugher (Curate)
on Jun 23, 2015 at 06:48 UTC ( #1131573=note: print w/replies, xml ) Need Help??


in reply to Re^2: recursion basics
in thread recursion basics

Check my first reply for a more detailed explanation, but the short version is that, each time the function calls itself, the caller stops and waits for the "child" function to finish. So none of the instances reach that final return until one of them returns from the first return, then they all finish and hit the second return in reverse order. Something like this:

binary1 calls binary2, stops and waits for it binary2 calls binary3, stops and waits for it binary3 calls binary4, stops and waits for it binary4 returns from the first return line ($n==1) binary3 finishes, returns binary2 finishes, returns binary1 finishes, returns print statement executes, printing binary1's return value

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2020-05-27 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (162 votes). Check out past polls.

    Notices?