Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (26 sloc) 0.587 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, $expected, "Greatest element of a list");
Jump to Line
Something went wrong with that request. Please try again.