Jump to content

Sum and product of an array: Difference between revisions

→‎{{header|APL}}: Added a comment on the superfluity of the sum and prod functions.
(→‎{{header|APL}}: Added link to Extended Dyalog APL solution executable on-line)
(→‎{{header|APL}}: Added a comment on the superfluity of the sum and prod functions.)
Line 265:
a ← 1 2 3 4 5 ⍝ assign a literal array to variable 'a'
sum a ⍝ or simply: +/a
15
prod a ⍝ or simply: ×/a
120</lang>
What follows ⍝ is a comment and / is usually known as ''reduce'' in APL. The use of the ''sum'' and ''prod'' functions is not necessary and was added only to please people baffled by the extreme conciseness of using APL symbols.
 
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.