eXist version: Stable 1.4 (Eindhoven)
We were writing a MIN function for arbitrary values, since we need the minimum of a series of dates and the built-in min() function doesn't handle this type. While writing our (recursive) function, we noticed invalid output.
In particular, the value returned by $sequence[1] seem to be inconsistent. However, this situation can be resolved by adding an UNREFERENCED let statement before the expression. See the attached file for an example.
The min1 function assigns the value of $sequence[1] to a variable called $head, although this variable is never referenced. This function produces the right answer.
In the min2 function, the unused assignment is removed. This function produces the answer '2' instead of the correct answer '1'.
rix0rrr
2010-06-14
File demonstrating issue
James Fuller
2010-08-13
I can confirm I get the wrong answer as well
and testing against Zorba they get the right answer ... will investigate
Dannes Wessels
2013-03-31
query results 1,1 on 2.0/2.1
Dannes Wessels
2013-03-31