RosettaCodeData/Task/Search-a-list/Perl-6/search-a-list-2.pl6
2016-12-05 22:15:40 +01:00

13 lines
360 B
Raku

my Str @haystack = <Zig Zag Wally Ronald Bush Krusty Charlie Bush Bozo>;
for <Washingston Bush> -> $needle {
my $first = @haystack.first($needle, :k);
if defined $first {
my $last = @haystack.first($needle, :k, :end);
say "$needle -- first at $first, last at $last";
}
else {
say "$needle -- not in haystack";
}
}