Posso paralelizar a execução usando o Hyper e funciona:
$ raku -e 'race for (^8).race(batch => 1, degree => 4) {sleep rand; .say}'
0
3
5
2
1
7
4
6
Mas como posso adicionar comportamento gather/take a esse loop?
Nessa abordagem, take não detectará que está encapsulado no contexto gather:
$ raku -e '
my @x = gather race for (^8).race(batch => 1, degree => 4) {
sleep rand;
take $_;
};
@x.say
'
Died at:
take without gather
Nessa abordagem, o gather consumirá o HyperSeq sem realmente "hiper" sobre ele:
$ raku -e '
my @x = race gather for (^8).race(batch => 1, degree => 4) {
sleep rand;
take $_;
};
@x.say
'
[0 1 2 3 4 5 6 7]