develooper Front page | perl.perl6.users | Postings from October 2020

cross reduce operator magic

Thread Next
Cezmi Pastirma
October 11, 2020 15:45
cross reduce operator magic
Message ID:
<div><div>I've got a question about a Leyland-numbers-listing Raku code which I saw at at</div><div> </div><div>I've slightly rearranged the code to make it print Leyland numbers up to 1 Billion:</div><div><strong>.say for grep {$_ &lt; 1E11}, squish(sort [X[&amp;({$^a**$^b+$b**$a})]] 2..32,2..32)</strong></div><div> </div><div>The question in short is:</div><div> </div><div>How does the cross reduce work there?</div><div> </div><div>Extra info:</div><div> </div><div>That cross reduce section surely does what this half-pseudo code tries to do:</div><div><strong>map { $^a ** $^b + $b ** $a }, 2..32,32...2</strong></div><div>The tricky part here is the use of reduce operators two times in a row, once before the cross operator, once before the &amp; operator, which I guess donates a closure. How to interpret this usage of operators?</div><div> </div></div>

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About