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.

1. Setup test data

The test data is regenerated for each script so the outputs are not the same. In this test the number of samples is 500 because the worst case takes forever with 5000.

Other tests runs : strings, elements

3. XQuery 1A - Distinct Values 2

as suggested by Michael Westbay

6. Group

suggested by Wolfgang Meier- requires XQuery 3.0 .