2 ms·
On a similar note, for max and min algorithms you actually do have a sensible initial element, which is the min or the max integer for the integer type in quest
by jerf 8y ago
On a similar note, for max and min algorithms you actually do have a sensible initial element, which is the min or the max integer for the integer type in question. However, you have to make sure this value can't escape into the caller's context (unless it really is the max value); calling max or min with an empty list ought to be an error in whatever the appropriate local error idiom is. The article (reasonably appropriately) glossed over that.