Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (26 sloc) 0.627 kB
# http://rosettacode.org/wiki/Greatest_element_of_a_list#Perl_6
use v6;
use Test;
plan 1;
my $rosetta-code = {
#### RC-begin
say [max] 17, 13, 50, 56, 28, 63, 62, 66, 74, 54;
say [max] 'my', 'dog', 'has', 'fleas';
sub max2 (*@a) { reduce -> $x, $y { $y after $x ?? $y !! $x }, @a }
say max2 17, 13, 50, 56, 28, 63, 62, 66, 74, 54;
#### RC-end
}
my $oldOUT = $*OUT;
my $output;
$*OUT = class {
method print(*@args) {
$output ~= @args.join;
}
}
$rosetta-code.();
my $expected = "74
my
74
";
$*OUT = $oldOUT;
is($output.subst("\r", '', :g), $expected.subst("\r", '', :g), "Greatest element of a list");
Jump to Line
Something went wrong with that request. Please try again.