Implement `sum` function w/o using an accumulator