cross reduce operator magic

2020-10-11 Thread Cezmi Pastirma
I've got a question about a Leyland-numbers-listing Raku code which I saw at codegolf.stackexchange.com at https://codegolf.stackexchange.com/a/83013/98132 I've slightly rearranged the code to make it print Leyland numbers up to 1 Billion:.say for grep {$_ < 1E11}, squish(sort [X[&({$^a**$^b+$b**$a

Re: cross reduce operator magic

2020-10-11 Thread Bruce Gray
NOTE: 30 minutes from now is the start of the Raku Study Group of the San Francisco Perl Mongers. We can offer a "deep dive" into how the Leyland code works, if that would be helpful. Zoom details here: https://mail.pm.org/pipermail/sanfrancisco-pm/2020-October/004726.html > On Oct 11, 2020, a

Re: cross reduce operator magic

2020-10-11 Thread Joseph Brenner
Bruce Gray wrote: > NOTE: 30 minutes from now is the start of the Raku Study Group of the San > Francisco Perl Mongers. Thanks-- though now it's 3 minutes-- but that was the info for last week. The current one is: https://www.meetup.com/San-Francisco-Perl/events/273839687/ In general, you ca

Re: cross reduce operator magic

2020-10-11 Thread Cezmi Pastirma
Wow, that's a very comprehensive explanation. I've just found out that I couldn't even comprehend the first reduction operator. I was thinking it was doing some magic operations. All it did was enable the cross op to act on the 2 lists without having to be  between   them. As simple as that. And su

Re: cross reduce operator magic

2020-10-11 Thread yary
Since this is a golf exercize, reducing number of characters, why use the reduction form when infix is shorter? squish(sort [X[&({$^a**$^b+$b**$a})]] 2..31,2..31) # from original squish(sort 2..31 X[&({$^a**$^b+$b**$a})] 2..31) # infix is 2-chars shorter Also I am trying to do a little un-golf sp

Re: cross reduce operator magic

2020-10-11 Thread yary
here's a way to not re-test a,b == b,a squish(sort flat map {$_..31 X[&({$^a**$^b+$b**$a})] $_},2..31) I'm not completely happy with it, but it does work and is about 30% faster squish(sort [X[&({$^a**$^b+$b**$a})]] 2..31,2..31) eqv squish(sort flat map {$_..31 X[&({$^a**$^b+$b**$a})] $_},2..31)