Sum and product of an array: Difference between revisions

no edit summary
No edit summary
Line 1,769:
foldl op+ 0.0 x;
foldl op* 1.0 x;</lang>
 
=={{header|Sparkling}}==
<lang Sparkling>spn:1> reduce({ 1, 2, 3, 4, 5 }, 0, function(x, y) { return x + y; })
= 15
spn:2> reduce({ 1, 2, 3, 4, 5 }, 1, function(x, y) { return x * y; })
= 120</lang>
 
=={{header|Swift}}==
Anonymous user