I wrote this code for this weeks challenge to produce ugly numbers.
sub factors( $n ) {
if $n > 1 {
$_, |factors $n div $_
given ( grep $n %% *, 2..* ).first } }
.say for ( 1, |grep *.&factors.all ∈ ( 2, 3, 5 ), 2..* )[^150];
This works, in the sense it produces the correct ouput, but it does not behave lazily: The output does not start right away but 30 seconds after the start.
However when I remove the indexing and iterate over the bare sequence
.say for 1, |grep *.&factors.all ∈ ( 2, 3, 5 ), 2..*;
I get output immedeatly as expected.
This is a bug, yes?