Sum and product of an array

From Fōrmulæ wiki
Jump to: navigation, search

This page is a solution to the task Sum and product of an array in the Rosetta Code, written in Fōrmulæ.

Description (from Rosetta Code)

Compute the sum and product of an array of integers.

Solution

SumAndProductOfAnArrayCode01.png

Alternative solution

SumAndProductOfAnArrayCode02.png

Cases

Both solutions retrieve the same results:

SumAndProductOfAnArrayCase01.png

Elements can be symbols:

SumAndProductOfAnArrayCase02.png

Any zero factor produces a product of zero:

SumAndProductOfAnArrayCase03.png

With empty lists:

SumAndProductOfAnArrayCase04.png