Sum with Block

I think that there's definitely room in a package like Swift Numerics for a sum function that lets you specify what you want:

data.sum(strategy: .reproducible)
data.sum(strategy: .correctlyRounded)
data.sum(strategy: .yolo)

I don't think that an API like this is a good fit for the standard library, and as others have suggested, I'm not sure that the simplest algorithm actually carries its weight.

20 Likes