Quick actions

cmd+k|ctrl+k

Navigation

Languages

Hockey

Snippet info

Language

Raku

Visibility

public

Author

grtodd

Created

2018-04-19T00:23:59Z

Updated

2021-12-28T00:44:21.95851Z

# A list of hockey teams - lists start with "@", variables start with "$"
my @teams = qww<Jets Leafs Sharks Penguins Capitals Oilers Wild "Red Wings">;
say "Teams that start with R or P";
for @teams -> $team { say "* $team" if $team ~~ /^R||P/ };

# Example of a subroutine 
sub is_canadian(@list) { 
    for @list -> $elem { 
        given $elem { 
            say "- $_ are Canadian"
            when /Jets|Leafs|Canadien|Oilers|Flames|Canucks|Senators/ 
        }
    }
}
say "\nRun our is_canadian() subroutine with \"@teams\" as the argument ..." ;
is_canadian(@teams)

INFO