|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: Re: Re: lookup-table thoughts (was Re: matchin
Dimitre,
> However, in the worst-case scenario, when the number of times must
> be not 1000 but a big prime number
You're right; asking for 1009 repetitions is just the kind of thing
that David would do.
Jeni
P.S. Calculating the next prime after 1000 made me write the following
(infinitely recursive) templates for generating prime numbers:
<xsl:template name="findPrimes">
<xsl:param name="prime" select="11" />
<xsl:param name="primes" select="'2/3/5/7/'" />
<xsl:variable name="divisor">
<xsl:call-template name="testPrime">
<xsl:with-param name="prime" select="$prime" />
<xsl:with-param name="primes" select="$primes" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="string($divisor)">
<xsl:call-template name="findPrimes">
<xsl:with-param name="prime" select="$prime + 2" />
<xsl:with-param name="primes" select="$primes" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message><xsl:value-of select="$prime" /></xsl:message>
<xsl:call-template name="findPrimes">
<xsl:with-param name="prime" select="$prime + 2" />
<xsl:with-param name="primes"
select="concat($primes, $prime, '/')" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="testPrime">
<xsl:param name="prime" />
<xsl:param name="primes" />
<xsl:variable name="divisor" select="substring-before($primes, '/')" />
<xsl:choose>
<xsl:when test="($divisor * $divisor) > $prime" />
<xsl:when test="not($prime mod $divisor)">
<xsl:value-of select="$divisor" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="testPrime">
<xsl:with-param name="prime" select="$prime" />
<xsl:with-param name="primes"
select="substring-after($primes, '/')" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








