Compiler issue?

Monday, 17 October 2016 · 3 messages
ML
Marco Lettere17 Oct 2016 19:49 #
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))]
CG
Christian Grün17 Oct 2016 21:59 #
Hi Marco,
Quoted text · Marco Lettere · 5 lines
> [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
ML
Marco Lettere17 Oct 2016 22:08 #
OMG. Sorry, after that many years some dark corner of my brain is still reasoning according to formerly used languages .... Grrr. Thanks. M. M.
Quoted text · Christian Grün · 14 lines
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

⚡Generated with XQuery