xsl-list
[Top] [All Lists]

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

2007-05-02 12:51:05
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--