DEV Community

loading...

Discussion on: Daily Challenge #225 - Square'n'Sum

Collapse
citizen428 profile image
Michael Kohl • Edited

Raku

With nothing else to do in lockdown, I made a Raku version too:

sub sum-squared(@a) { [+] (@a >>*<< @a) }

Or single-pass with reduce:

sub sum-squared(@a) { reduce { $^a + $^b ** 2}, 0, |@a }