RosettaCodeData/Task/Longest-string-challenge/Perl-6/longest-string-challenge.pl6
Ingy döt Net 6f050a029e update
2013-06-05 21:47:54 +00:00

13 lines
362 B
Raku

my $l = ''; # Sample longest string seen.
my $a = ''; # Accumulator to save longest strings.
while get() -> $s {
my $n = "$s\n";
if $n.substr($l.chars) { # Is new string longer?
$a = $l = $n; # Reset accumulator.
}
elsif !$l.substr($n.chars) { # Same length?
$a ~= $n; # Accumulate it.
}
}
print $a;