Products and sums over lists #
The alternating sum of a list.
Equations
- List.alternatingSum [] = 0
- List.alternatingSum [g] = g
- List.alternatingSum (g :: h :: t) = g + -h + List.alternatingSum t
Instances For
The alternating product of a list.
Equations
- List.alternatingProd [] = 1
- List.alternatingProd [g] = g
- List.alternatingProd (g :: h :: t) = g * h⁻¹ * List.alternatingProd t