Re: [xsl] How is memory allocated in recursive XSLT templates?

Subject: Re: [xsl] How is memory allocated in recursive XSLT templates?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 02 May 2007 21:03:31 +0200
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