Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday December 19, 2006
05:36 PM

'pick' in Pugs

[ #31970 ]

luqui has now implemented 'pick' in Pugs:

my @rand = <a b c d e f g h>.pick(3);
is @rand.elems, 3, 'pick() should return the correct number of items';
ok all(@rand) ~~ any(@letters), '... and they should be in the letters';

But .pick should return unique elements. Let's test that:

my $compress = sub ($x) {
    state $previous;
    return $x ne $previous ?? ($previous = $x) !! ();
}
is map( $compress, 1 .. 1000 ).pick(999).elems, 999,
    'pick() should be unique';

Yup. Lots of fun with Pugs :)

Note how I tested the junctions, though. The following not only ran 8 tests, but it also spewed a bunch of garbage all over my screen!

use v6-alpha;
use Test;
plan 1;

is 'b', any('a' .. 'h'), 'junctions should work';

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.