Anonymous user
Sum and product of an array: Difference between revisions
→{{header|APL}}: Added a solution with the pair primitive function in dzaima/APL and Extended Dyalog APL
(→{{header|APL}}: Added a solution with the pair primitive function in dzaima/APL and Extended Dyalog APL) |
|||
Line 260:
=={{header|APL}}==
{{works with|APL2}}
<lang apl> sum ← +/ ⍝ sum (+) over (/) an array
prod ← ×/ ⍝ product (×) over (/) an array
sum
15
prod
120</lang>
What follows ⍝ is a comment and / is usually known as ''reduce'' in APL.
{{works with|dzaima/APL}}
{{works with|Extended Dyalog APL}}
using the [https://aplwiki.com/wiki/Pair pair (⍮)] primitive function ([https://tio.run/##SyzI0U2pSszMTfz//1Hf1EdtEzS09R/1rjs8XV/TUMFIwVjBRMH0/38A try it online])
<lang apl> ⎕ ← (+/ ⍮ ×/) 1 2 3 4 5
15 120</lang>
=={{header|AppleScript}}==
|