# function random_choose
# randomly chooses $n elements without repetition and returns them
sub random_choose {
    my $n = shift;          # parameter 1: how many elements
                            # the rest of the parameters are elements
    return () if $n<1;
    die "no enough elements" if $n > $#_+1;
    return @_                if $n == $#_+1;

    my @r;
    while ($#r+1 < $n) {
	my $i = rand($#_+1);
	push @r, $_[$i];
	splice(@_, $i, 1);
    }
    return @r;
}
# end of function random_choose
#
# Documentation Note:
#
# (c) Vlado Keselj 2004-2007 http://www.cs.dal.ca
# Available at: http://www.cs.dal.ca/~vlado/srcperl/snip/random_choose
#
# $Id: random_choose,v 1.3 2007/03/15 12:15:03 vlado Exp $
1;
