Sum and product of an array: Difference between revisions
Content added Content deleted
Line 654: | Line 654: | ||
<pre>Sum of the elements of the array: 30 |
<pre>Sum of the elements of the array: 30 |
||
Product of the elements of the array: 3840</pre> |
Product of the elements of the array: 3840</pre> |
||
=={{header|Elena}}== |
|||
<lang elena>#import system. |
|||
#import system'routines. |
|||
#import extensions. |
|||
#symbol program = |
|||
[ |
|||
#var list := (1, 2, 3, 4, 5 ). |
|||
#var sum := list summarize:(Integer new). |
|||
#var product := list accumulate:(Integer new:1) &with:(:var:val) [ var *= val ]. |
|||
].</lang> |
|||
=={{header|Elixir}}== |
=={{header|Elixir}}== |