Sum of squares: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: for clarity, enclose numeric list (two ways))
Line 2,390: Line 2,390:
=={{header|Raku}}==
=={{header|Raku}}==
(formerly Perl 6)
(formerly Perl 6)
<lang perl6>say [+] map * ** 2, (3, 1, 4, 1, 5, 9);</lang>
{{works with|Rakudo|#21 "Seattle"}}

<lang perl6>say [+] map * ** 2, 3, 1, 4, 1, 5, 9;</lang>


If this expression seems puzzling, note that <code>* ** 2</code> is equivalent to <code>{$^x ** 2}</code>— the leftmost asterisk is not the multiplication operator but the <code>Whatever</code> star, which specifies currying behavior.
If this expression seems puzzling, note that <code>* ** 2</code> is equivalent to <code>{$^x ** 2}</code>— the leftmost asterisk is not the multiplication operator but the <code>Whatever</code> star, which specifies currying behavior.
Line 2,398: Line 2,396:
as a list infix is looser than comma in precedence but tighter than the reduction list operator:
as a list infix is looser than comma in precedence but tighter than the reduction list operator:


<lang perl6>say [+] 3,1,4,1,5,9 X** 2</lang>
<lang perl6>say [+] <3 1 4 1 5 9> X** 2</lang>


=={{header|Raven}}==
=={{header|Raven}}==