Find duplicates in sequences of numbers

Task: To locate duplicate values in a sequence of numbers

This set was suggested by a post from Robby Pelssers Blog where he and commenters have measured the performance of different algorithms on Sedna, XBase and Zorba.
A similar question was also asked on StackOverflow
This set conpares performance on a sequence of numbers. There are also sets to compare strings and elements.
Script Title Repetitions Average msec * XQuery length
setup Setup test data 1 3 104
group Group 1 4 139
distinct-values XQuery 1 - Distinct Values 1 59 221
index-of XQuery 2 : index-of() 1 91 97
distinct-values2 XQuery 1A - Distinct Values 2 1 366 219
count XQuery 3 1 369 223
* relative times are more useful than absolute times. At present the execution time includes compilation of locally-declared functions although the code is cached.