I'm caching the results of a few recursive function in an object that create a tree structure of the site nav and a linked breadcrumb trail for each page in the site. So the performance hit is only taken once in a great while. I DO have to agree with Sean that the code is much more elegant, and the depth of the tree is unlimited, something i didn't see how to do with loops, (but might now if i really thought about it.)
The next challenge is how to "prune" the siteMap tree to display only the navigation tree needed for a particular page - hopefully that's easy, but i haven't looked into it yet. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Sean A Corfield > Sent: Monday, December 01, 2003 11:40 PM > To: [EMAIL PROTECTED] > Subject: Re: [CFCDev] recursive functions > > > On Dec 1, 2003, at 1:47 PM, Patrick Branley wrote: > > This is a very good point. Anything that can be done with recursion > > can also > > be done using a loop. > > Sometimes implementing an algorithm with a loop makes for horrendous > code whereas recursive code can be elegant and simple - consider > algorithms for processing tree-structured data! > > > Does anybody know if there is a performance increase ? I would assume > > there > > isnt. > > It depends. Recursion relies on function calls which can be expensive > (creating a stack frame, pushing variables etc). If the algorithm is > sufficiently complex, the extra work you have to do to manage 'context' > for a loop may exceed the function call overhead. > > Sean A Corfield -- http://www.corfield.org/blog/ > > "If you're not annoying somebody, you're not really alive." > -- Margaret Atwood > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
