sum method

num sum()

Calculates the sum of all numbers in the list.

Returns 0 if the list is empty.

Implementation

num sum() {
  return fold(0, (sum, element) => sum + element);
}