[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How is memory allocated in recursive XSLT template

Subject: Re: How is memory allocated in recursive XSLT templates?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 02 May 2007 21:03:31 +0200
Re:  How is memory allocated in recursive XSLT template
PS:

Rashmi Rubdi wrote:

I was trying to achieve the equivalent of the recursive Factorial function illustrated here with procedural programming: http://www.oopweb.com/Algorithms/Documents/PLDS210/Volume/recursion.html




<xsl:function name="f:fac" as="xs:integer">
<xsl:param name="nr" as="xs:integer" />
<xsl:sequence select="if($nr = 0) then 1 else f:fac($nr -1) * $nr" />
</xsl:function>


Which gives in a split second for:
<xsl:sequence select="f:fac(100)" />

93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

Not that bad for an interpreted language, my calculator is not that precise...

Cheers,
-- Abel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.