Skip to content

Commit

Permalink
pick() is now implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jul 20, 2013
1 parent 43db15c commit 0a12a9c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions integration/99problems-21-to-30.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ plan 15;
# (E D A)
#
# Hint: Use the built-in random number generator and the result of problem P20.

sub rand_select(Int $count, *@list) returns List {
# from Larry (on #perl6): well, pick(3) is specced to do that but is unimplemented.
return map { @list[floor (@list.elems).rand] }, 1 .. $count;
}
my @letters = 'a' .. 'h';
my @rand = rand_select(3, @letters);
is @rand.elems, 3, 'rand_select() should return the correct number of items';
my @rand = pick(3, @letters);
is @rand.elems, 3, 'pick() should return the correct number of items';

# of course the following is wrong, but it also confuses test output!
#ok all(@rand) ~~ none(@letters), '... and they should be in the letters';
Expand Down

0 comments on commit 0a12a9c

Please sign in to comment.