Sum and product puzzle: Difference between revisions
Content added Content deleted
(Added (efficient) code for Matlab) |
(→{{header|Raku}}: `sum` on lists is already defined) |
||
Line 2,330: | Line 2,330: | ||
<syntaxhighlight lang="raku" line>sub grep-unique (&by, @list) { @list.classify(&by).values.grep(* == 1).map(*[0]) } |
<syntaxhighlight lang="raku" line>sub grep-unique (&by, @list) { @list.classify(&by).values.grep(* == 1).map(*[0]) } |
||
sub sums ($n) { ($_, $n - $_ for 2 .. $n div 2) } |
sub sums ($n) { ($_, $n - $_ for 2 .. $n div 2) } |
||
sub sum ([$x, $y]) { $x + $y } |
|||
sub product ([$x, $y]) { $x * $y } |
sub product ([$x, $y]) { $x * $y } |
||