[Home] [By Thread] [By Date] [Recent Entries]
My 2c:
I used an XQuery function based on Dmitry's version before; it works fine although it's a little inconvenient to have to keep passing in the prior value. I would say the most convenient (or at least the most familiar) signature for a random function is random($n) returning a random number between 0 inclusive and $n exclusive; ideally it would return integers if $n is an integer, floating point numbers if $n is a floating point number, empty if $n is empty ? and an error otherwise. And I would like a seed function. Ideally this should be callable many times: I'm not sure how that could be done non-deterministically though. I suppose a sequence would be useful, but it isn't the first thing that leaps to mind. What if I'm not sure how many I'll need? For example, one use case for me was to load a huge amount of data, and only include 1% of it, in order to generate a predictable test data sub-set. I want to write an XSLT template that returns nothing 99% of the time, and for the other 1% of the time it processed the content normally. I want this to be based on an identifier in the content so that for a given seed, the same "random" 1% are selected each time: it should *not* be order-dependent, rather I would like to seed the random number generator with a hash of a given seed that is a configuration parameter, and a node-identifier, and then evaluate the next random number to see if it is > 0.01 (say). Maybe there are other ways to do that, but that is what I did using Java. -Mike On 5/6/2014 6:58 PM, Michael Kay wrote: The big problem with a nondeterministic random() function is not defining the order of execution, but preventing it being optimised out of a loop. For example, how do we ensure that
|

Cart



