Raku .hyper() 和 .race() 示例不起作用

Raku .hyper() and .race() example not working

以下示例代码应加速 Raku 程序的执行:

for (1..4).race()  {
    say "Doing $_";
    sleep 1;
 }
 say now - INIT now;

我记得,它在一段时间前有效,但现在我总是以 4 秒 运行 时间结束。同样使用 .race() 或添加参数不会改变任何东西。我需要做什么才能同时 运行 2 个进程?

你应该使用 race with the named argument batch and the statement prefix race.

say race for (1..4).race(batch=>1)  {
    say "Doing $_";
    sleep 1.rand;$_
}
say now - INIT now;