Raku By Example
View me onGitHub
# 生成 A1a, B1b...A2a...E2e 这样的字符串
my @prefixes  = 'A'..'E';  # 前缀
my @roots     = 1, 2;      # 根
my @postfixes = 'a'..'e';  # 后缀

say @roots.map: |(@prefixes »~» * «~« @postfixes);

# Output: (A1a B1b C1c D1d E1e A2a B2b C2c D2d E2e)

# hyper with sub

sub add($x) {
    # sleep 3;    
    $x ** 2 + 1;
}
# hyper  运算符现在还未实现并行, 该程序 sleep 了 9 秒
my @array = 1, 3, 5;
.say for @array».&add;

# race

for (1..4).race( batch => 1 ) {
    say "Doing $_";
    sleep 1;
}
say "Code took {now - INIT now} seconds to run";