in reply to removing the goto

use Python or LISP.

Replies are listed 'Best First'.
Re^2: removing the goto
by TimToady (Parson) on Jun 02, 2007 at 20:34 UTC
    Or use Perl 6:
    @results = @input.pick(*).uniq.[^$numwanted];
    or some such...

    Now that I think of it, if the shuffler (.pick(*)) is sufficiently lazy, that gets around all the problems of the other solutions. It doesn't need to visit all the values, but it'll still visit all the values if you ask for more values than exist uniquely, so it's also guaranteed to terminate.