Dear BaseX team,
running the following two queries [1,2] (which should be semantically equivalent to my eyes) I get different results. In particular [2] sometimes return multiple results or empty sequence which is pretty odd, isn't it?
I've tried on 8.5.3 and on a recent snapshot labeled 8.5.4 (beta 6e9bf7c).
Regards,
Marco.
[1]
let $domain := for $record in (1 to 100) where $record mod 5 = 0 return $record let $index := 1 + random:integer(count($domain)) return $domain[$index]
[2]
let $domain := for $record in (1 to 100) where $record mod 5 = 0 return $record return $domain[1 + random:integer(count($domain))]
Hi Marco,
[1] let $index := 1 + random:integer(count($domain))
[2] $domain[1 + random:integer(count($domain))]
please note that in [1] only one random integer is computed, wheras a new random value is computed in [2] for each evaluation of the predicate.
Cheers Christian
OMG. Sorry, after that many years some dark corner of my brain is still reasoning according to formerly used languages .... Grrr. Thanks. M.
M.
On 17/10/2016 21:59, Christian Grün wrote:
Hi Marco,
[1] let $index := 1 + random:integer(count($domain))
[2] $domain[1 + random:integer(count($domain))]
please note that in [1] only one random integer is computed, wheras a new random value is computed in [2] for each evaluation of the predicate.
Cheers Christian
basex-talk@mailman.uni-konstanz.de