Returns sum of int values by elements.
getVal should return value for sum up. It can be property of element, or any another value by element.
getVal
int sumOf(GetValue<E, int> getVal) => fold(0, (sum, e) => sum + getVal(e));