ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> python-Tutor
python-Tutor
Re: [Tutor] parsing--is this right?
by Paul Tremblay other posts by this author
Jun 12 2002 2:38AM messages near this date
Re: [Tutor] parsing--is this right? | Re: [Tutor] parsing--is this right? [function evaluation / errors for fun and profit]
On Tue, Jun 11, 2002 at 02:06:57PM -0700, Danny Yoo wrote:

Thanks Derrick and Danny.

Recursion is both intuitive and counter-intuitive. For example,
Derrick showed a fairly simple example using a factorial. But what
happens to the return in this line?

return n * fact( n-1 )

You think of return as getting one value, but the return somehow
has to wait and build up a value. Also, how come the function
doesn't return 1? The first part of the function says that it
should return 1 if n is equal to one. At some point, n becomes 1.
So why don't we see 1, and why doesn't the function stop?

On the other hand, recusion is intuititve in a way that is just
beyond my reach. I say this because I have written so much
duplicate code, and I'm always thinking, "How can I re-use this
code?" Of course, not all of this code is an example of
recursion, but I bet if I went back and looked, some of the
problems would be.

Anyway, all this should give me a bit to think about for a while.

Paul


-- 

************************
*Paul Tremblay         *
*phthenry@earthlink.net*
************************


_______________________________________________
Tutor maillist  -  Tutor@[...].org
http://mail.python.org/mailman/listinfo/tutor
Thread:
Danny Yoo
Paul Tremblay
Danny Yoo
Danny Yoo

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved