random-between
($lower as integer, $upper as integer) as integer
This function generates one random number within a given range. |
random-between
($lower as integer, $upper as integer, $num as integer) as integer*
This function generates an arbitrary number of random numbers within a given range. |
random
() as integer
This function generates one random number. |
random
($num as integer) as integer* external
This function generates an arbitrary number of random numbers. |
seeded-random-between
($seed as integer, $lower as integer, $upper as integer, $num as integer) as integer*
This function generates an arbitrary number of pseudo-random numbers within a given range. |
seeded-random
($seed as integer, $num as integer) as integer* external
This function generates an arbitrary number of pseudo-random numbers. |
uuid
() as string external
This function returns a uuid. |
declare %an:nondeterministic function r:random-between($lower as integer, $upper as integer) as integer
This function generates one random number within a given range. The function is nondeterministic.
The function is based on r:random-between#3. Specifically, it returns the value of invoking r:random-betwen($lower, $upper, 1).
declare %an:nondeterministic function r:random-between($lower as integer, $upper as integer, $num as integer) as integer*
This function generates an arbitrary number of random numbers within a given range. The function is nondeterministic because the sequence is not repeatable.
declare %an:nondeterministic function r:random() as integer
This function generates one random number. The function is nondeterministic.
The function is based on r:random#1. Specifically, it returns the value of invoking r:random(1).
declare %an:nondeterministic function r:random($num as integer) as integer* external
This function generates an arbitrary number of random numbers. The function is nondeterministic because the sequence is not repeatable.
However, the function is based on posix function srand() and rand(). Specifically, it invokes srand() with some random number based on the current time and then returns the values returned by invoking rand() $num-times.
declare function r:seeded-random-between($seed as integer, $lower as integer, $upper as integer, $num as integer) as integer*
This function generates an arbitrary number of pseudo-random numbers within a given range. The sequence is repeatable by calling the function with the same seed and boundaries.
The function is based on the function r:seeded-random#2. Specifically, its result is repeatable if called with the same arguments.
declare function r:seeded-random($seed as integer, $num as integer) as integer* external
This function generates an arbitrary number of pseudo-random numbers. The sequence is repeatable by calling the function with the same seed.
The function is based on posix function srand() and rand(). Specifically, it invokes srand($seed) and then returns the values returned by invoking rand() $num-times.
Sequences returned by this function are not thread-safe (i.e. if multiple XQuery programs invoking this function are executed concurrently in several threads). This is because the function is based on srand() and rand().
declare %an:nondeterministic function r:uuid() as string external
This function returns a uuid.
Note, that the function is not stable, that is, it returns a different UUID everytime the function is invoked.