Task

Compute the sum and product of an array of integers.




void
compute(integer &s, integer &p, list l)
{
    integer v;
 
    s = 0;
    p = 1;
    for (, v in l) {
        s += v;
        p *= v;
    }
}
 
integer
main(void)
{
    integer sum, product;
 
    compute(sum, product, list(2, 3, 5, 7, 11, 13, 17, 19));
 
    o_form("~\n~\n", sum, product);
 
    return 0;
}