xsl-list
[Top] [All Lists]

Re: [xsl] Seed problem in FXSL randomizeList

2009-10-07 05:51:16
Thanks for the hint Michael.

I now do this for the first seed:
xs:integer(format-time(current-time(), '[s][f]'))

The sequence of positions returned is then kept in a variable x like this:

<xsl:variable name="x">
   <xsl:call-template name="randomizeList">
    <xsl:with-param name="pList" select="(1 to count(/items/item))[. != $num]"/>
    <xsl:with-param name="pSeed" select="$pSeed" as="xs:integer"/>
   </xsl:call-template>
  </xsl:variable>

The second seed is then generated like this:

xs:integer(substring(string-join($x/el[position() &lt; 6], ''), 1, 4))

Etc, and again for the third seed, etc, and it looks like it works well.
I'm now more confident that the pseudo-randomization is random!

Cheers,
Jesper

http://www.xmlplease.com

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>