Sorry for not finding the specific problem before. > while($not_prime && $!number++) { > $not_prime = @!primes.grep({$!number % $^a == 0}); > }
The problem with Rakudo is that it is setting @!primes to a list containing a single item (the latest value of $!number) on each turn through the loop. Saying $not_prime after the expression: > while($not_prime && $!number++) { > $not_prime = @!primes.grep({$!number % $^a == 0}); > say $not_prime; > } shows $not_prime is being set to the current value of $!number. And of course, since $not_prime is always true, the loop never exits. What I don't understand it why it works on the first time through, but never after that. Oh, as an added bonus, adding the say causes a segfault.