Re: trouble returning a value from sub

2022-06-17 Thread Rick Bychowski
Clever! I had missed checking "is-prime" straight away! Checked some large primes, and my function hung badly. Thank you! Is grep running on all "2 ..^ $n/2" values, and then picking the first, or is that somehow lazily evaluated? I assume the former, or you'd have no need to halve $n. But

The SF Perl Raku Study Group, 06/19 at 1pm PDT

2022-06-17 Thread Joseph Brenner
Frederick P. Brooks, from the additional material in the 1995 edition of "The Mythical Man-Month" (1975): "Much more is known today about software engineering than was known in 1975. Which of the assertions in the original 1975 edition have been supported by data and experience?

Re: trouble returning a value from sub

2022-06-17 Thread Simon Proctor
Here's my new go to prime-factors function : sub prime-factors( Int $n is copy where * > 1 ) { gather { while ( $n > 1 ) { if ( $n.is-prime ) { take $n; last; } my $f = (2..^$n/2).grep($n %% *).first(*.is-prime);