[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: "Rashmi Rubdi" <rashmi.sub@xxxxxxxxx>
Date: Wed, 2 May 2007 16:03:27 -0400
Re:  How is memory allocated in recursive XSLT template
On 5/2/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
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

Wow , that is amazing!


I have written this in Java, my program fails to calculate anything
greater than factorial 16 which is 2004189184 ,  I think the
limitation is occurring because I've used an int data type.
May be if I change it to long or BigInteger, I might get a bigger
number but i'll test the limits :-)

Thanks a lot for the solution, I will try your code and see if I can
compare the limits with 2 programming languages, just for the sake of
curiosity.


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

Cheers,
-- Abel

-Regards Rashmi

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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.