Sum and product of an array: Difference between revisions

Content added Content deleted
(→‎{{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: Line 265:
a ← 1 2 3 4 5 ⍝ assign a literal array to variable 'a'
a ← 1 2 3 4 5 ⍝ assign a literal array to variable 'a'
sum a
sum a ⍝ or simply: +/a
15
15
prod a
prod a ⍝ or simply: ×/a
120</lang>
120</lang>
What follows ⍝ is a comment and / is usually known as ''reduce'' in APL.
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.