sum method
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);
}
Calculates the sum of all numbers in the list.
Returns 0 if the list is empty.
num sum() {
return fold(0, (sum, element) => sum + element);
}