Jump to content

Sum and product of an array: Difference between revisions

rm what seems a duplicate, even if a little bit different in syntax (Standard ML twice)
m (smalltalk lang tag)
(rm what seems a duplicate, even if a little bit different in syntax (Standard ML twice))
Line 828:
<lang smalltalk> #(1 2 3 4 5) fold: [:sum :number | sum + number]
#(1 2 3 4 5) fold: [:product :number | product * number]</lang>
 
=={{header|Standard ML}}==
val array = [1,2,3,4,5];
foldl op+ 0 array;
foldl (op*) 1 array;
 
=={{header|Standard ML}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.